freescale

来自「Freescale 系列单片机常用模块与综合系统设计」· 代码 · 共 69 行

TXT
69
字号
/** ###################################################################
**     Filename  : I2C.C
**     Project   : I2C
**     Processor : MC9S08JM60CLHE
**     Version   : Driver 01.11
**     Compiler  : CodeWarrior HCS08 C Compiler
**     Date/Time : 2009-11-16, 17:22
**     Abstract  :
**         Main module.
**         This module contains user's application code.
**     Settings  :
**     Contents  :
**         No public methods
**
**     (c) Copyright UNIS, spol. s r.o. 1997-2008
**     UNIS, spol. s r.o.
**     Jundrovska 33
**     624 00 Brno
**     Czech Republic
**     http      : www.processorexpert.com
**     mail      : info@processorexpert.com
** ###################################################################*/
/* MODULE I2C */


/* Including needed modules to compile this module/procedure */
#include "Cpu.h"
#include "Events.h"
/* Include shared modules, which are used for whole project */
#include "PE_Types.h"
#include "PE_Error.h"
#include "PE_Const.h"
#include "IO_Map.h"

void main(void)
{
  /* Write your local variable definition here */

  /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
  PE_low_level_init();
  /*** End of Processor Expert internal initialization.                    ***/
  IIC_init();                   //初始化IIC模块
  IIC_read_block(0x20,12);      //读取IIC存储芯片数据
  delay(10000);
  while(length,IIC_Res_flg==0); //等待数据读取完成
  for(m=0;m<16;m++)
      data[m]=200-5*m;          //写入待发送的数据
  IIC_write_block(0x20,16);     //写入数据到IIC存储芯片
  for(m=180;m>0;m--) 
       delay(60000);
  while(length,IIC_Res_flg==0); //等待数据写入完成
  delay(60000);
  for(m=0;m<10;m++)             //清零数据数组
      data[m]=0x0;
  delay(10000);
  IIC_read_block(0x20,16);      //重新读取读取IIC存储芯片数据
  while(length,IIC_Res_flg==0); 
  delay(60000);
}
/* END I2C */
/*
** ###################################################################
**
**     This file was created by UNIS Processor Expert 3.03 [04.07]
**     for the Freescale HCS08 series of microcontrollers.
**
** ###################################################################
*/

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?