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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? interrupt.#2

?? 本代碼是用C8051F330 MCU對24LC256EEPROM的讀寫和與RS232終端以9600BPS速率通信代碼.
?? #2
字號:
#define INT_ISR_C


#include "c8051F330.h"
#include "rs232.h"


char rece,count_UART,count_UART1;
char Rec_OK,Tran_OK;
char Tran_Flag;
char xdata  sSendComBuf[8],sRecComBuf[8];
char *pointer;
void UART_Isr(void)  interrupt 4
{
	ES0 = 0x0;
	if(TI0)
		{
			SCON0 &=0xFD;
			Tran_Flag=0;
			if (count_UART1==8)
				Tran_OK=0x45;
				
		}
 	else
		{
			SCON0 &=0xFE;
			*pointer++ = SBUF0;
			count_UART++;
			if (count_UART==8)
			{
				Rec_OK=0x23;
			}
			
		}
	ES0 = 0x1;	 
} 





//------------------------------------------------------------------------------------
// Timer3 Interrupt Service Routine (ISR)
//------------------------------------------------------------------------------------
//
// A Timer3 interrupt indicates an SMBus SCL low timeout.
// The SMBus is disabled and re-enabled here
//
void Timer3_ISR (void) interrupt 14
{
   SMB0CF &= ~0x80;          // Disable SMBus
   SMB0CF |= 0x80;           // Re-enable SMBus
   TMR3CN &= ~0x80;          // Clear Timer3 interrupt-pending flag
}






//------------------------------------------------------------------------------------
// SMBus Interrupt Service Routine (ISR)
//------------------------------------------------------------------------------------
//
// SMBus ISR state machine
// - Master only implementation - no slave or arbitration states defined
// - All incoming data is written starting at the global pointer <pSMB_DATA_IN>
// - All outgoing data is read from the global pointer <pSMB_DATA_OUT>
//
void SMBus_ISR (void) interrupt 7
{
   bit FAIL = 0;                             // Used by the ISR to flag failed
                                             // transfers

   static char i;                            // Used by the ISR to count the
                                             // number of data bytes sent or
                                             // received

   static bit SEND_START = 0;                // Send a start

   switch (SMB0CN & 0xF0)                    // Status vector
   {
      // Master Transmitter/Receiver: START condition transmitted.
      case SMB_MTSTA:
         SMB0DAT = TARGET;                   // Load address of the target slave
         SMB0DAT |= SMB_RW;                  // Load R/W bit
         STA = 0;                            // Manually clear START bit
         i = 0;                              // reset data byte counter
         break;

      // Master Transmitter: Data byte (or Slave Address) transmitted
      case SMB_MTDB:
         if (ACK)                            // Slave Address or Data Byte
         {                                   // Acknowledged?
            if (SEND_START)
            {
               STA = 1;
               SEND_START = 0;
               break;
            }
            if(SMB_SENDWORDADDR)             // Are we sending the word address?
            {
               SMB_SENDWORDADDR = 0;         // Clear flag
               SMB0DAT = WORD_ADDR;          // send word's high 8bits address

              /* if (SMB_RANDOMREAD)
               {
                  SEND_START = 1;            // send a START after the next ACK cycle
                  SMB_RW = READ;
               }*/

               break;
            }

		else if(SMB_SENDWORDADDR1)             // Are we sending the word address?
            {
               SMB_SENDWORDADDR1 = 0;         // Clear flag
               SMB0DAT = WORD_ADDR1;          // send word's low 8bits address

               if (SMB_RANDOMREAD)
               {
                  SEND_START = 1;            // send a START after the next ACK cycle
                  SMB_RW = READ;
               }

               break;
            }

            if (SMB_RW==WRITE)               // Is this transfer a WRITE?
            {

               if (i < SMB_DATA_LEN)         // Is there data to send?
               {
                  SMB0DAT = *pSMB_DATA_OUT;  // send data byte
                  pSMB_DATA_OUT++;           // increment data out pointer
                  i++;                       // increment number of bytes sent
               }
               else
               {
                 STO = 1;                    // set STO to terminte transfer
                 SMB_BUSY = 0;               // clear software busy flag
               }
            }
            else {}                          // If this transfer is a READ,
                                             // then take no action. Slave
                                             // address was transmitted. A
                                             // separate 'case' is defined
                                             // for data byte recieved.
         }
         else                                // If slave NACK,
         {
            if(SMB_ACKPOLL)
            {
               STA = 1;                      // Restart transfer
            }
            else
            {
               FAIL = 1;                     // Indicate failed transfer
            }                                // and handle at end of ISR
         }
         break;

      // Master Receiver: byte received
      case SMB_MRDB:
         if ( i < SMB_DATA_LEN )             // Is there any data remaining?
         {
            *pSMB_DATA_IN = SMB0DAT;         // Store received byte
            pSMB_DATA_IN++;                  // Increment data in pointer
            i++;                             // Increment number of bytes received
            ACK = 1;                         // Set ACK bit (may be cleared later
                                             // in the code)

         }

         if (i == SMB_DATA_LEN)              // This is the last byte
         {
            SMB_BUSY = 0;                    // Free SMBus interface
            ACK = 0;                         // Send NACK to indicate last byte
                                             // of this transfer
            STO = 1;                         // Send STOP to terminate transfer
         }

         break;

      default:
         FAIL = 1;                           // Indicate failed transfer
                                             // and handle at end of ISR
         break;
   }

   if (FAIL)                                 // If the transfer failed,
   {
      SMB0CN &= ~0x40;                       // Reset communication
      SMB0CN |= 0x40;
      SMB_BUSY = 0;                          // Free SMBus
   }

   SI=0;                                     // clear interrupt flag
}



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

//------------------------------------------------------------------------------------
// EEPROM_ByteWrite ()
//------------------------------------------------------------------------------------
//
// 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 int addr, unsigned char dat )
{
   while (SMB_BUSY);                         // Wait for SMBus to be free.
   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 high 8bits Word Address after Slave Address
   SMB_SENDWORDADDR1 = 1;                     // Send low 8bits 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 
                                             // acknoledge its address.

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

   WORD_ADDR1 = addr%256;                         // 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 int addr)
{
   unsigned char retval;                     // Holds the return value

   while (SMB_BUSY);                         // Wait for SMBus to be free.
   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 high 8bits Word Address after Slave Address
   SMB_SENDWORDADDR1 = 1;                     // Send low 8bits Word Address after Slave Address
   SMB_RANDOMREAD = 1;                       // Send a START after the word address
   SMB_ACKPOLL = 1;                          // Enable Acknowledge Polling


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

   WORD_ADDR1 = addr%256;                         // Set the target address in the 
                                             // EEPROM's internal memory space

   pSMB_DATA_IN = &retval;                   // The incoming data pointer points to
                                             // the <retval> variable.

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

   // Initiate SMBus Transfer
   STA = 1;
   while(SMB_BUSY);                          // Wait until data is read

   return retval;

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩视频一区二区| 成人国产精品视频| 激情都市一区二区| 成人av电影在线播放| 欧美视频在线一区二区三区| 久久精品视频一区| 一区二区三区免费网站| 国模一区二区三区白浆| 欧美日韩国产小视频在线观看| 久久亚洲精精品中文字幕早川悠里 | 欧美亚洲自拍偷拍| 国产亚洲精品aa| 青青草97国产精品免费观看无弹窗版| 播五月开心婷婷综合| 日韩一区二区三区三四区视频在线观看| 亚洲人成在线观看一区二区| 国产乱色国产精品免费视频| 欧美美女一区二区在线观看| 中文字幕字幕中文在线中不卡视频| 国产在线国偷精品产拍免费yy| 在线视频欧美精品| 亚洲人成网站在线| 成人黄色在线视频| 国产偷国产偷精品高清尤物| 麻豆91在线观看| 欧美日韩免费一区二区三区视频| 中文字幕在线视频一区| 国产美女娇喘av呻吟久久| 欧美一区二区三区在线电影| 亚洲国产视频一区二区| 91豆麻精品91久久久久久| 中文字幕亚洲不卡| 99精品欧美一区二区三区综合在线| 精品久久久久久久人人人人传媒| 亚洲不卡在线观看| 欧美高清视频不卡网| 丝袜美腿一区二区三区| 欧美日韩一区二区不卡| 婷婷亚洲久悠悠色悠在线播放| 91国偷自产一区二区三区观看| 亚洲欧美日本在线| 色噜噜狠狠一区二区三区果冻| 国产精品成人免费| 91蜜桃传媒精品久久久一区二区| 国产精品毛片久久久久久久| 成人app软件下载大全免费| 国产婷婷色一区二区三区在线| 国产一区二区主播在线| 欧美极品少妇xxxxⅹ高跟鞋| 成人精品视频网站| 伊人色综合久久天天人手人婷| 在线观看亚洲专区| 日本女人一区二区三区| 久久久久国产成人精品亚洲午夜| 国产乱码精品一区二区三区av| 国产三级欧美三级日产三级99| 成人综合在线观看| 夜夜嗨av一区二区三区中文字幕| 欧美人xxxx| 国产一区二区三区免费| 国产精品久久久久影院色老大| 色综合一区二区三区| 首页国产欧美日韩丝袜| 日韩你懂的电影在线观看| 国产精品性做久久久久久| 亚洲免费看黄网站| 欧美顶级少妇做爰| 国产不卡视频一区二区三区| 一区二区三区中文免费| 日韩欧美一卡二卡| av亚洲精华国产精华| 日韩在线播放一区二区| 国产欧美日韩激情| 欧美日韩亚洲综合在线| 韩国毛片一区二区三区| 亚洲美女视频一区| 26uuu亚洲婷婷狠狠天堂| hitomi一区二区三区精品| 日韩精品1区2区3区| 中文字幕国产一区| 91精品免费在线观看| 99视频一区二区三区| 蜜臀精品一区二区三区在线观看 | 色综合天天狠狠| 五月综合激情网| 中文幕一区二区三区久久蜜桃| 欧美中文字幕不卡| 国产成人在线色| 免费欧美日韩国产三级电影| 亚洲日韩欧美一区二区在线| 精品欧美乱码久久久久久1区2区| 91国偷自产一区二区开放时间| 国产精品456露脸| 日本中文字幕一区二区视频| 亚洲欧美日韩在线不卡| 欧美高清一级片在线观看| 日韩免费在线观看| 欧美精品色综合| 在线观看亚洲精品视频| 不卡av在线免费观看| 精品制服美女久久| 视频一区在线播放| 一区二区理论电影在线观看| 中文字幕在线不卡| 国产欧美精品一区二区三区四区| 亚洲精品在线免费播放| 欧美精品久久天天躁| 欧美视频一区二区三区在线观看 | 亚洲视频在线一区二区| 欧美激情一区二区三区四区| 精品毛片乱码1区2区3区| 777久久久精品| 欧美一区日本一区韩国一区| 欧美日韩中文国产| 91国偷自产一区二区三区观看| 91啪亚洲精品| 91久久国产最好的精华液| 在线视频综合导航| 在线观看亚洲一区| 欧美男生操女生| 日韩一二在线观看| 精品三级在线看| 精品国产一区二区国模嫣然| 精品国产a毛片| 久久久亚洲午夜电影| 国产精品欧美经典| 亚洲三级小视频| 亚洲1区2区3区4区| 麻豆国产一区二区| 国产一区久久久| av在线一区二区| 欧美日韩综合在线免费观看| 欧美日韩一级黄| 日韩写真欧美这视频| 精品国产在天天线2019| 久久精品视频免费观看| 亚洲欧美一区二区三区久本道91| 一区二区三区四区乱视频| 亚洲第一狼人社区| 乱中年女人伦av一区二区| 国产一区二区三区黄视频 | 日韩精品国产欧美| 韩国av一区二区三区在线观看| 国产91精品在线观看| 91老师片黄在线观看| 欧美高清一级片在线| 国产亚洲综合色| 亚洲激情av在线| 麻豆91在线播放| 成人激情开心网| 欧美精品日韩精品| 日本一区二区三区四区| 亚洲图片有声小说| 成人永久免费视频| 欧美精品在线一区二区三区| 国产日韩欧美高清| 亚洲国产欧美日韩另类综合| 韩国av一区二区三区在线观看| 色综合久久久久久久久| 日韩欧美资源站| 亚洲品质自拍视频网站| 九一九一国产精品| 色一情一乱一乱一91av| 精品国产乱码久久久久久久久 | 处破女av一区二区| 欧美一区二区三区四区高清| 中文字幕中文字幕一区二区| 日本女优在线视频一区二区| 91麻豆高清视频| 久久精品人人做人人爽人人| 亚洲一级二级三级| 粉嫩av亚洲一区二区图片| 欧美老人xxxx18| 亚洲色图20p| 国产一区二区在线观看免费| 欧美日韩亚洲另类| 国产精品成人免费| 国产99久久久国产精品| 欧美一区二区日韩| 亚洲图片欧美色图| 91蜜桃免费观看视频| 中日韩免费视频中文字幕| 国内精品写真在线观看 | 97精品电影院| 久久亚洲精华国产精华液| 免费在线观看不卡| 欧美日韩国产区一| 亚洲一区影音先锋| 色综合激情五月| 亚洲欧洲国产日韩| 成人自拍视频在线观看| 国产亚洲精品bt天堂精选| 久久精品国产一区二区三| 在线电影一区二区三区| 亚洲乱码国产乱码精品精的特点| 大桥未久av一区二区三区中文| 国产亚洲成av人在线观看导航 | 日韩亚洲欧美成人一区| 日韩电影在线一区二区| 正在播放亚洲一区|