色婷婷AⅤ一区二区三区|亚洲精品第一国产综合亚AV|久久精品官方网视频|日本28视频香蕉

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > AVR128的程序——EEPROM記錄復(fù)位次數(shù)

          AVR128的程序——EEPROM記錄復(fù)位次數(shù)

          作者: 時間:2016-11-22 來源:網(wǎng)絡(luò) 收藏
          #include
          #include
          #define uchar unsigned char
          #define uintunsigned int
          void EEPROM_write(uint EEPROM_ADDR, uchar EEPROM_DAT);
          void Delayms(uint MS);
          void display(uchar FirstBit,uchar Num);
          void Mcu_IO_Init(void);
          uchar EEPROM_read(uint EEPROM_ADDR);
          uchar TempData[8];
          uchar WeiMa[8] = {0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
          uchar led_discode[11]={0xc0,0xf9,0xa4,0xb0,0x99,
          0x92,0x82,0xf8,0x80,0x90,0xff};
          void main(void)
          {
          uchar i;
          Mcu_IO_Init();
          i=EEPROM_read(1);
          i++;
          EEPROM_write(1,i);
          TempData[2] = led_discode[i/100];
          TempData[1] = led_discode[i];
          TempData[0] = led_discode[i/10];
          while(1)
          {
          display(6,2);
          }
          }
          void Mcu_IO_Init(void)
          {
          DDRA=0XFF;
          PORTA=0XFF;
          DDRC=0XFF;
          PORTC=0XFF;
          DDRF|=0X0E;
          PORTF|=0X0E;
          PORTF&=0xF7;
          DDRB |=0X10;
          PORTB|=0X10;
          }
          void EEPROM_write(uint EEPROM_ADDR, uchar EEPROM_DAT)
          {
          CLI();
          while(EECR & (1<
          EEARH = 0X00;
          EEARL = EEPROM_ADDR;
          EEDR = EEPROM_DAT;
          EECR |= (1<
          EECR |= (1<
          SEI();
          }
          uchar EEPROM_read(uint EEPROM_ADDR)
          {
          CLI();
          while(EECR & (1<
          EEARH = 0X00;
          EEARL = EEPROM_ADDR;
          EECR |= (1<
          return EEDR;
          SEI();
          }
          void display(uchar FirstBit,uchar Num)
          {
          unsigned char i;
          for(i=0;i
          {
          PORTC=led_discode[10];
          PORTA=WeiMa[i+FirstBit];
          PORTC=TempData[i];
          Delayms(5);
          }
          }
          void Delayms(uint MS)
          {
          uint i,j;
          for( i=0;i
          for(j=0;j<1141;j++);
          }


          關(guān)鍵詞: AVR128EEPROM復(fù)位次

          評論


          技術(shù)專區(qū)

          關(guān)閉