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

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

?? 24c04test.c

?? BTF330實(shí)驗(yàn)程序。針對(duì)c8051f330的大部分外設(shè)的實(shí)驗(yàn)程序
?? C
?? 第 1 頁 / 共 2 頁
字號(hào):
/*------------------------------------------------------------------------------------
插上短路環(huán)J10、J21。斷開短路環(huán)J8.
    P0.6 -> SDA (SMBus)
    P0.7 -> SCL (SMBus)
功能:把寫到EEPROM的值讀出來。在液晶上顯示 SMBUS 0xCC.如24C02損壞,則顯示24C02 ERROR。
------------------------------------------------------------------------------------*/
// Includes
//------------------------------------------------------------------------------------
#include <c8051f330.h>                       // SFR declarations
#include <intrins.h>
#include "common.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)						//有按鍵按下,顯示對(duì)應(yīng)的按鍵
	{
    	YJ_Init();                     //LCD初始化
                                        //準(zhǔn)備送數(shù)據(jù)
		
		for(ii=0;ii<10;ii++){
  			Write_CHAR(tabn[ii]);
  		
		}		                 	//控制LCD	
		mysleep_ms();

	}
	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);
		mysleep_ms();
		
	}

}

//------------------------------------------------------------------------------------
// 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
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
麻豆精品视频在线观看视频| 久久精品网站免费观看| 日韩视频免费直播| 国产拍欧美日韩视频二区| 一区二区三区精品视频在线| 国产一区二区美女| 欧美日韩国产免费一区二区| 中文字幕av一区二区三区免费看| 天天影视涩香欲综合网| 99国产欧美久久久精品| 精品处破学生在线二十三| 午夜国产精品影院在线观看| 99久久久久免费精品国产| 久久久一区二区| 美国十次了思思久久精品导航| 日本黄色一区二区| 亚洲欧洲美洲综合色网| 国产成人8x视频一区二区| 精品国产免费视频| 蜜臀99久久精品久久久久久软件| 欧美影视一区在线| 亚洲在线视频一区| 91麻豆免费看| 自拍偷自拍亚洲精品播放| 粉嫩aⅴ一区二区三区四区 | 日本一区二区三区dvd视频在线| 亚洲电影中文字幕在线观看| 99久久er热在这里只有精品66| 久久九九久久九九| 国产电影精品久久禁18| 国产视频911| 成人的网站免费观看| 中文字幕精品综合| gogo大胆日本视频一区| 亚洲视频一区二区在线观看| 9久草视频在线视频精品| 中文字幕国产一区| 99re这里只有精品首页| 亚洲自拍偷拍九九九| 欧美日韩一级二级三级| 偷拍与自拍一区| 91精品国产美女浴室洗澡无遮挡| 日本三级韩国三级欧美三级| 精品国产一区二区三区久久久蜜月 | 国产一区二区电影| 国产女人aaa级久久久级| 国产成人av一区二区三区在线| 久久九九全国免费| 91免费小视频| 日韩中文欧美在线| 久久一日本道色综合| 成人免费视频国产在线观看| 亚洲欧美偷拍三级| 欧美精品精品一区| 国产精品亚洲人在线观看| 国产精品免费视频观看| 欧美午夜精品久久久久久孕妇| 日韩精品一区第一页| 国产午夜久久久久| 在线一区二区视频| 欧美a级一区二区| 中文字幕乱码久久午夜不卡| 欧美日韩国产精选| 国产一区二区按摩在线观看| 亚洲靠逼com| xvideos.蜜桃一区二区| 色94色欧美sute亚洲13| 久久 天天综合| 亚洲男女一区二区三区| 日韩午夜精品视频| 色综合中文字幕| 国产麻豆精品一区二区| 亚洲444eee在线观看| 久久精品一区二区三区不卡牛牛 | 一区二区三区中文在线| 2欧美一区二区三区在线观看视频| av动漫一区二区| 韩国精品主播一区二区在线观看 | 亚洲精品一区二区在线观看| 色综合中文字幕国产 | 久久免费视频色| 精品视频在线看| 成人性色生活片免费看爆迷你毛片| 亚洲男女毛片无遮挡| 亚洲精品在线电影| 91精品婷婷国产综合久久性色 | 精品一区二区三区欧美| 亚洲国产成人av网| 国产精品国产三级国产aⅴ原创| 欧美一级午夜免费电影| 在线观看日韩av先锋影音电影院| 国产伦理精品不卡| 麻豆精品久久久| 午夜伦欧美伦电影理论片| 亚洲精品日韩专区silk| 欧美韩国一区二区| 久久久久久影视| 日韩色在线观看| 欧美卡1卡2卡| 欧美日韩精品一区视频| 色婷婷av一区| www.亚洲精品| 99久久99久久综合| 97久久超碰精品国产| 成人伦理片在线| 床上的激情91.| 国产麻豆精品theporn| 国产伦精品一区二区三区在线观看| 日本不卡免费在线视频| 日本va欧美va瓶| 男女男精品视频| 日韩国产欧美在线播放| 日本美女一区二区三区| 日韩精品成人一区二区在线| 亚洲va中文字幕| 日韩国产高清影视| 午夜久久福利影院| 麻豆一区二区三| 激情图片小说一区| 99久久综合精品| 色哟哟在线观看一区二区三区| aaa欧美日韩| 欧美色国产精品| 91精品国产欧美一区二区成人| 欧美精品久久99久久在免费线 | 粉嫩13p一区二区三区| av一区二区不卡| 日本精品视频一区二区| 欧美久久高跟鞋激| 精品国内片67194| 欧美激情一区二区三区不卡| 国产精品久久久久影院| 亚洲欧美另类小说| 三级精品在线观看| 国产呦萝稀缺另类资源| 9l国产精品久久久久麻豆| 欧美色综合影院| 精品国产第一区二区三区观看体验| 久久蜜桃一区二区| 亚洲免费大片在线观看| 免费精品视频在线| 粉嫩高潮美女一区二区三区| 欧美性高清videossexo| 精品免费一区二区三区| 中文字幕一区二区三区在线观看| 亚洲综合激情另类小说区| 久久精品噜噜噜成人88aⅴ| heyzo一本久久综合| 91精品国产色综合久久不卡电影 | 成a人片国产精品| 欧美日韩精品欧美日韩精品一综合 | 中文字幕精品一区二区精品绿巨人| 日韩一区在线免费观看| 日本在线不卡视频| 粉嫩av一区二区三区| 欧美一区二区三区四区久久| 中文av一区二区| 免费亚洲电影在线| 色悠悠久久综合| 久久精品人人做人人爽人人| 亚洲午夜影视影院在线观看| 国产宾馆实践打屁股91| 91精品国产综合久久精品app| 中文字幕av资源一区| 精品在线亚洲视频| 在线一区二区三区四区| 国产日产欧美一区| 免费三级欧美电影| 欧美在线观看视频一区二区三区| 久久精品夜色噜噜亚洲a∨| 性做久久久久久| 日本久久一区二区| 中文字幕日本不卡| 国产精品一区二区你懂的| 91精品国产一区二区三区| 一区二区三区在线视频播放| 国产一本一道久久香蕉| 欧美一区二区网站| 性做久久久久久免费观看欧美| av不卡一区二区三区| 中文字幕的久久| 国产成人精品综合在线观看| 欧美xxxx老人做受| 蜜臀av国产精品久久久久| 欧美老人xxxx18| 亚洲va中文字幕| 欧美亚洲国产一区在线观看网站| 国产精品国产三级国产普通话99| 国产一区二区电影| 久久久国产一区二区三区四区小说| 日本sm残虐另类| 日韩欧美激情一区| 久久精品国产网站| 日韩三级高清在线| 精品亚洲aⅴ乱码一区二区三区| 日韩欧美国产1| 国产一区二区三区久久悠悠色av| 精品精品国产高清a毛片牛牛| 捆绑紧缚一区二区三区视频| 久久在线观看免费|