亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? fm24c04test.c

?? 含24bitAD的C8051F350單片機的測試程序
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*------------------------------------------------------------------------------------
插上短路環(huán)J15.
    P0.6 -> SDA (SMBus)
    P0.7 -> SCL (SMBus)
功能:把寫到EEPROM的值讀出來。在液晶上顯示 SMBUS 0xCC.如24C02損壞,則顯示24C02 ERROR。
------------------------------------------------------------------------------------*/
// Includes
//------------------------------------------------------------------------------------
#include <c8051f350.h>                       // SFR declarations
#include <intrins.h>

//------------------------------------------------------------------------------------
// Global CONSTANTS
//------------------------------------------------------------------------------------

#define  SYSCLK         24500000             // System clock frequency
#define  SMB_FREQUENCY  50000                // Target SCL clock rate

#define  WRITE          0x00                 // SMBus WRITE command
#define  READ           0x01                 // SMBus READ command

                                             // Device addresses (7 bits, lsb is a don't care)
#define  EEPROM_ADDR    0xA0                 // Device address for slave target
                                             // Note: This address is specified
                                             // in the Microchip 24LC02B
                                             // datasheet.
// SMBus Buffer Size
#define  SMB_BUFF_SIZE  0x08                 // Defines the maximum number of bytes
                                             // that can be sent or received in a
                                             // single transfer

// Status vector - top 4 bits only
#define  SMB_MTSTA      0xE0                 // (MT) start transmitted
#define  SMB_MTDB       0xC0                 // (MT) data byte transmitted
#define  SMB_MRDB       0x80                 // (MR) data byte received
// End status vector definition
void YJ_Init(void);
void Write_CHAR(unsigned char yjchar);
//sbit  LED=P1^0;
//------------------------------------------------------------------------------------
// Global VARIABLES
//------------------------------------------------------------------------------------
unsigned char* pSMB_DATA_IN;                 // Global pointer for SMBus data
                                             // All receive data is written here

unsigned char SMB_SINGLEBYTE_OUT;            // Global holder for single byte writes

unsigned char* pSMB_DATA_OUT;                // Global pointer for SMBus data.
 //unsigned long q;                                            // All transmit data is read from here

unsigned char SMB_DATA_LEN;                  // Global holder for number of bytes
                                             // to send or receive in the current
                                             // SMBus transfer

unsigned char WORD_ADDR;                     // Global holder for the EEPROM word
                                             // address that will be accessed in
                                             // the next transfer

unsigned char TARGET;                        // Target SMBus slave address
 unsigned char temp_char;                  // temporary variable

unsigned char retval;  
bit SMB_BUSY = 0;                            // Software flag to indicate when the
                                             // EEPROM_ByteRead() or 
                                             // EEPROM_ByteWrite()
                                             // functions have claimed the SMBus

bit SMB_RW;                                  // Software flag to indicate the
                                             // direction of the current transfer

bit SMB_SENDWORDADDR;                        // When set, this flag causes the ISR
                                             // to send the 8-bit <WORD_ADDR>
                                             // after sending the slave address


bit SMB_RANDOMREAD;                          // When set, this flag causes the ISR
                                             // to send a START signal after 
                                             // sending the word address

bit SMB_ACKPOLL;                             // When set, this flag causes the ISR
                                             // to send a repeated START until the
                                             // slave has acknowledged its address

// 16-bit SFR declarations
sfr16    TMR2RL   = 0xca;                    // Timer2 reload registers
sfr16    TMR2     = 0xcc;                    // Timer2 counter registers
sfr16    TMR3RL   = 0x92;                    // Timer2 reload registers
sfr16    TMR3     = 0x94;                    // Timer3 counter registers

//------------------------------------------------------------------------------------
// Function PROTOTYPES
//------------------------------------------------------------------------------------

void SMBus_Init (void);
void Timer1_Init (void);
void Timer3_Init (void);
void Port1_Init (void);
void SMBus_ISR (void);
void Timer3_ISR (void);

void EEPROM_ByteWrite(unsigned char addr, unsigned char dat);
void EEPROM_WriteArray (unsigned char dest_addr, unsigned char* src_addr,
                        unsigned char len);
unsigned char EEPROM_ByteRead(unsigned char addr);
void EEPROM_ReadArray (unsigned char* dest_addr, unsigned char src_addr,
                       unsigned char len);
unsigned char xdata tabn[10]={0x53,0x4d,0x42,0x55,0x53,0x20,0x30,0x78
,0x43,0x43};
//------------------------------------------------------------------------------------
// MAIN Routine
//------------------------------------------------------------------------------------
//
// Main routine performs all configuration tasks, then loops forever sending and
// receiving SMBus data to the slave F300_SLAVE

void main (void)
{
	int iNum = 0;
	int ii;
   	

	PCA0MD &= ~0x40;                          // WDTE = 0 (disable watchdog timer)

   	OSCICN |= 0x03;                           // Set internal oscillator to highest
                                             // setting (24500000)
   	Port1_Init ();                             // Initialize Crossbar and GPIO

   	Timer1_Init ();                           // Configure Timer1 for use as SMBus
                                             // clock source

   	Timer3_Init ();                           // Configure Timer2 for use with SMBus
                                             // low timeout detect
    
   	SMBus_Init ();                            // Configure and enable SMBus

	EIE1 = 1;                                // SMBus interrupt enable
   	IE = 0x20;                               // Timer2 interrupt enable
   	EA = 1;                                   // Global interrupt enable

   	EEPROM_ByteWrite(0x38, 0xcc);
   	temp_char = EEPROM_ByteRead(0x38);

  	if(temp_char==0xcc)						//有按鍵按下,顯示對應(yīng)的按鍵
	{
    	YJ_Init();                     //LCD初始化
                                        //準(zhǔn)備送數(shù)據(jù)
		
		for(ii=0;ii<10;ii++){
  			Write_CHAR(tabn[ii]);
  		
		}		                 	//控制LCD	


	}
	else{	
		YJ_Init();
		Write_CHAR(0x32);
		Write_CHAR(0x34);
		Write_CHAR(0x43);
		Write_CHAR(0x30);
		Write_CHAR(0x34);
		Write_CHAR(0x20);
		Write_CHAR(0x45);
		Write_CHAR(0x52);
		Write_CHAR(0x52);
		Write_CHAR(0x4f);
		Write_CHAR(0x52);

		
	}

}

//------------------------------------------------------------------------------------
// Functions
//------------------------------------------------------------------------------------

//------------------------------------------------------------------------------------
// EEPROM_Write ()
//------------------------------------------------------------------------------------
//
// This function writes the value in <dat> to location <addr> in the EEPROM then polls
// the EEPROM until the write is complete.
//
void EEPROM_ByteWrite( unsigned char addr, unsigned char dat )
{
   while (SMB_BUSY);
   SMB_BUSY = 1;                             // Claim SMBus (set to busy)

   // Set SMBus ISR parameters
   TARGET = EEPROM_ADDR;                     // Set target slave address
   SMB_RW = WRITE;                           // Mark next transfer as a write
   SMB_SENDWORDADDR = 1;                     // Send Word Address after Slave Address
   SMB_RANDOMREAD = 0;                       // Do not send a START signal after
                                             // the word address
   SMB_ACKPOLL = 1;                          // Enable Acknowledge Polling (The ISR
                                             // will automatically restart the 
                                             // transfer if the slave does not 
                                             // acknowledge its address.

   // Specify the Outgoing Data
   WORD_ADDR = addr;                         // Set the target address in the EEPROM's
                                             // internal memory space

   SMB_SINGLEBYTE_OUT = dat;                 // store dat (local variable) in a global
                                             // variable so the ISR can read it after
                                             // this function exits

   pSMB_DATA_OUT = &SMB_SINGLEBYTE_OUT;      // The outgoing data pointer points to
                                             // the <dat> variable.

   SMB_DATA_LEN = 1;                         // Specify to ISR that the next transfer
                                             // will contain one data byte

   // Initiate SMBus Transfer
   STA = 1;

}



//------------------------------------------------------------------------------------
// EEPROM_ByteRead ()
//------------------------------------------------------------------------------------
//
// This function returns a single byte from location <addr> in the EEPROM then 
// polls the <SMB_BUSY> flag until the read is complete.
//
unsigned char EEPROM_ByteRead( unsigned char addr)
{
  // unsigned char retval;                     // Holds the return value

	int iLim1 = 100;
	int iLim2 = 25000;
	int  iNum1 = 0;
	int iNum2 = 0;
   	while (SMB_BUSY && iNum1 <iLim1 )
   	{
		while(SMB_BUSY && iNum2 < iLim2)
		{
			iNum2++;
		}
		iNum2 = 0;
		iNum1++;
   	}                         // Wait for SMBus to be free.
	if( iNum1 >= iLim1)
	{
		return 0xcb;			
	}
   SMB_BUSY = 1;                             // Claim SMBus (set to busy)

   // Set SMBus ISR parameters
   TARGET = EEPROM_ADDR;                     // Set target slave address
   SMB_RW = WRITE;                           // A random read starts as a write
                                             // then changes to a read after
                                             // the repeated start is sent. The
                                             // ISR handles this switchover if
                                             // the <SMB_RANDOMREAD> bit is set.
   SMB_SENDWORDADDR = 1;                     // Send Word Address after Slave Address
   SMB_RANDOMREAD = 1;                       // Send a START after the word address
   SMB_ACKPOLL = 1;                          // Enable Acknowledge Polling

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲天堂中文字幕| 欧美日韩三级在线| 国产精品全国免费观看高清| 国内外成人在线| 久久久精品免费网站| 国产精品99久久久久久有的能看 | 欧美成人在线直播| 午夜精品久久久久久久99水蜜桃| 99久久精品99国产精品| 久久九九久久九九| 国产精品一区二区免费不卡 | 日韩国产精品久久| 丰满少妇在线播放bd日韩电影| 欧美日韩成人高清| 日韩成人精品在线| 日韩亚洲国产中文字幕欧美| 亚洲一区二区综合| 欧美日韩一级二级三级| 亚洲精品久久久久久国产精华液| 国产不卡免费视频| 26uuu国产一区二区三区| 日韩电影一区二区三区四区| 欧美三级三级三级| 五月天中文字幕一区二区| 99精品视频在线观看| 亚洲少妇30p| 99久免费精品视频在线观看 | 在线播放视频一区| 亚洲最大成人网4388xx| 欧美性做爰猛烈叫床潮| 日韩国产精品久久久久久亚洲| 日韩精品在线一区二区| 国产精品一区二区免费不卡| 18涩涩午夜精品.www| 欧美三级蜜桃2在线观看| 蜜芽一区二区三区| 久久免费精品国产久精品久久久久| 国产激情视频一区二区三区欧美| 国产精品毛片无遮挡高清| 国产福利91精品| 国产精品欧美一区喷水| 成人精品视频一区| 亚洲激情欧美激情| 欧美一区二区女人| 日韩成人精品在线| 精品国产麻豆免费人成网站| 午夜精品一区二区三区电影天堂 | 国产欧美精品一区aⅴ影院| 色综合天天综合网国产成人综合天| 亚洲一区二区欧美| 久久精品一二三| 在线日韩一区二区| 经典三级一区二区| 亚洲男帅同性gay1069| 欧美一级久久久久久久大片| 豆国产96在线|亚洲| 亚洲超碰精品一区二区| 欧美精品一区二区不卡| 在线免费观看日本一区| 国产乱码精品一区二区三区五月婷| 亚洲精品一二三四区| 久久久精品人体av艺术| 欧美年轻男男videosbes| 成人精品电影在线观看| 日韩电影免费在线| 伊人夜夜躁av伊人久久| 2023国产精华国产精品| 欧美性一级生活| 成人免费观看男女羞羞视频| 人妖欧美一区二区| 亚洲最大的成人av| 国产精品成人免费精品自在线观看 | 国产成人免费视频一区| 亚洲成a人片在线观看中文| 国产精品视频九色porn| 精品粉嫩超白一线天av| 欧美精品亚洲一区二区在线播放| 成人免费观看视频| 国产一区二区视频在线| 奇米888四色在线精品| 夜夜夜精品看看| 日韩理论片中文av| 中文字幕成人在线观看| 久久亚洲精精品中文字幕早川悠里| 欧美精品在线一区二区| 色美美综合视频| av中文字幕不卡| 大胆欧美人体老妇| 国产成人精品一区二区三区四区| 精品中文字幕一区二区| 日韩电影在线免费看| 亚洲电影在线免费观看| 亚洲人精品午夜| 国产精品不卡视频| 国产精品免费丝袜| 国产精品素人视频| 国产精品天美传媒沈樵| 欧美国产精品久久| 国产日韩三级在线| 国产日韩欧美一区二区三区乱码 | 亚洲一区二区视频在线观看| 综合激情成人伊人| 亚洲三级电影全部在线观看高清| 中文字幕精品一区二区三区精品| 中文字幕欧美国产| 国产精品久久久久毛片软件| 亚洲欧洲99久久| 亚洲欧美日韩一区| 自拍偷拍国产亚洲| 亚洲精品免费在线观看| 亚洲最新在线观看| 日韩电影在线免费观看| 激情综合色丁香一区二区| 免费在线观看一区| 免费观看30秒视频久久| 免费的成人av| 久久激五月天综合精品| 久久99国产精品免费| 另类中文字幕网| 久久精品国产第一区二区三区| 久久精品国产99国产| 男人的j进女人的j一区| 久久99国产精品尤物| 国产精品原创巨作av| 国产高清久久久| 在线精品亚洲一区二区不卡| 在线播放日韩导航| 国产欧美视频一区二区三区| 自拍偷拍国产精品| 奇米精品一区二区三区在线观看一| 国产一区二区美女诱惑| 99re8在线精品视频免费播放| 欧美四级电影网| 精品国产乱码久久久久久浪潮| 国产精品污www在线观看| 夜夜亚洲天天久久| 国内外成人在线视频| 91捆绑美女网站| 欧美成人精品高清在线播放| 国产精品国模大尺度视频| 图片区日韩欧美亚洲| 美国毛片一区二区三区| 国产一区二区久久| 不卡欧美aaaaa| 欧美亚洲综合色| 久久精品一区二区三区av| 亚洲一区二区在线免费观看视频 | 中文一区二区在线观看| 亚洲va中文字幕| 不卡在线视频中文字幕| 欧美一卡二卡在线| 一级精品视频在线观看宜春院 | 国模娜娜一区二区三区| 99re这里只有精品首页| 91精品啪在线观看国产60岁| 久久午夜老司机| 一区二区三区中文字幕| 裸体健美xxxx欧美裸体表演| av电影在线观看一区| 欧美一区二区免费视频| 国产精品成人在线观看| 日韩av午夜在线观看| 成人免费va视频| 日韩视频在线一区二区| 亚洲欧洲美洲综合色网| 国产乱人伦偷精品视频不卡| 欧美区在线观看| 一区二区三区精品视频在线| 成人美女视频在线观看18| 久久亚洲综合av| 免费看黄色91| 777色狠狠一区二区三区| 亚洲免费在线观看视频| 成人三级在线视频| 久久精品一区八戒影视| 卡一卡二国产精品| 7777女厕盗摄久久久| 亚洲国产你懂的| 欧美在线观看视频一区二区| 亚洲三级久久久| av不卡免费在线观看| 国产日韩欧美精品一区| 麻豆91免费观看| 日韩一卡二卡三卡国产欧美| 亚洲成在线观看| 在线播放/欧美激情| 一区二区欧美视频| 国产福利一区二区| 精品国产不卡一区二区三区| 五月婷婷激情综合| 欧美最新大片在线看| 亚洲柠檬福利资源导航| 一本一道久久a久久精品| 国产欧美一二三区| 国产成人午夜电影网| 久久久一区二区三区捆绑**| 成人av网址在线| 亚洲人成网站精品片在线观看| 91美女精品福利| 亚洲国产成人精品视频|