MSP430F449单片机RTC时钟C语言程序(带闹钟)

发布者:幸福微风最新更新时间:2015-09-08 来源: eefocus关键字:MSP430F449  单片机  RTC时钟 手机看文章 扫描二维码
随时随地手机看文章
功能: 实现软件万年历功能,并自动识别闰年,A屏每显示5秒种就自动切换到B屏,B屏再显示5秒种就自动切换到C屏,C屏再显示5秒种就自动切换到A屏,通过按键在A屏、B屏和C屏之间切换 ,可通过按键手动设定和调整时间,当调整时对应调整位要有闪烁功能,有闹钟功能,可设置几点几分闹钟,当前时间等于闹钟时间时,用点亮LED指示,直到某个键(自定义)被按下时,熄灭LED灯 

***************************************************/   

#include      

   

unsigned char cnt;                                                  // 计数器    

unsigned char tian;                                                 // 天寄存器    

unsigned char key_code;                                             // 按键值    

unsigned char flag;                                                 // 换屏标志位    

unsigned char twinkle_num;                                          // 闪烁标志位     

unsigned char function_flag;                                        // 加减功能标志位    

unsigned char function_ping1,function_ping2,function_ping3;         // 每屏闪烁位    

unsigned char change_num;                                           // 闪屏时间定时    

unsigned char change_ping;                                          // 三屏计数位    

unsigned char clock_flag;                                           // 闹钟标志位    

unsigned char ping_flag;                                            // 按键跟踪闪屏标志位   

unsigned char num_flag;                                             // 按键计数闪屏标志位   

unsigned char tian_flag;                                            // 天判断标志位    

unsigned char run_flag;                                             // 闰年判断标志位    

unsigned int key_num 150;                                         // 按键消逗延时时间   

unsigned int year 2008;                                           // 年    

unsigned char month 2;                                            // 月    

unsigned char day 28;                                             // 日    

unsigned char hour 23;                                            // 小时    

unsigned char min 59;                                             // 分    

unsigned char sec 57;                                             // 秒    

unsigned char nao_hour 0;                                         // 闹钟时    

unsigned char nao_min 0;                                          // 闹钟分    

unsigned char nao_sec 0;                                          // 闹钟秒    

const unsigned char tianshu[13]   

{0,31,28,31,30,31,30,31,31,30,31,30,31};                            // 每月天数表    

char digit[12]                                                    // 液晶显示段码表     

  

  0x7b,   

  0x12,   

  0x4f,   

  0x1f,   

  0x36,   

  0x3d,   

  0x7d,   

  0x13,   

  0x7f,   

  0x3F,   

  0x00    

};     

   

void init_clk(void);                                                // 初始化时钟    

void key_scan(void);                                                // 按键扫描    

void key_value(void);                                               // 按键值确定    

void rtc(void);                                                     // 时钟扫描函数    

void rtc_show(void);                                                // rtc扫描函数                                                      

void leap_year(void);                                               // 闰年判定函数    

   

void main(void)                                                       

  

  init_clk();                                                       // 时钟初始化    

  while(1)   

    

    key_scan();                                                     // 按键扫描    

    key_value();                                                    // 键值确定    

    rtc_show();                                                     // RTC显示    

    leap_year();                                                    // 闰年判定    

    if((sec == nao_sec) && (min == nao_min) && (hour == nao_hour))  // 闹钟判定    

      

      clock_flag 1;                                               // 闹钟标志位置一    

      

    

  

   

void init_clk(void)   

  

  unsigned char i;   

  WDTCTL WDTPW WDTHOLD;                                         // 关闭看门狗            

  FLL_CTL0 |= XCAP14PF;                                             // 选择14PF电容                   

  IE2 |= BTIE;                                                      // 开启基本定时器中断                                   

  BTCTL BT_ADLY_250 BTFRFQ1;                                    // 250ms  16分频    

  LCDCTL LCDON LCD4MUX LCDP2;                                 // STK LCD 4Mux, S0-S14    

  P5SEL 0xFC;                                                     // 选择P5口第二功能    

  P1DIR |= 0x01;                                                    // P1.0选择输出       

  _EINT();                                                          // 开总中断    

  for (i=0; i<19; i++)   

    

    LCDMEM[i] 0;                                                  //清LCD缓冲区    

     

  

   

void key_scan(void)   

   

  static unsigned int num;                                          // 按键消抖计数器     

  if((P1IN&0x0e) != 0x0e)                                           // 如果不等于表示有键按下     

    

    num++;                                                          // 消逗计数器加    

    key_code 0;                                                   // 键值清零    

           

  else   

    

    num 0;                                                        // 按键抖动,键值清零   

    key_code 0;                                                   // 键值清零    

    

  if(num == key_num                                               // 键值确定    

          

    num 0;                                                        // 消逗寄存器清零    

    twinkle_num 0;                                                // 闪烁清零    

    key_code ((P1IN&0x0e)>>1)^0x07;                               // 键值转换       

    

  

   

void key_value(void)   

  

  if(key_code == 0x01)                                              // 第一个键被按下    

    

    function_flag 1;                                              // 功能键标志位置一   

    clock_flag 2;                                                 // 关闭闹钟    

    if(change_ping == 0)                                            // 第一屏    

      

      function_ping1 ++;                                            // 数值闪烁加    

      if(function_ping1 == 4)                                       // 闪烁到第三位             

         

        if(tian_flag == 1)   

          

          function_ping1 1;                                       //     

          

        else   

          

          function_ping1 0;                                       // 清零    

          function_flag 0;                                        // 功能键清零    

          

        

      change_num 0;                                               // 换屏计数器    

      

    if(change_ping == 1)                                            // 第二屏    

      

      function_ping2++;                                             // 数值闪烁加    

      if(function_ping2 == 4)   

        

        function_ping2 0;   

        function_flag 0;                                          // 清零                                                                   // 功能标志位清零    

        

      change_num 20;                                              // 换屏时间计数器    

      

    if(change_ping == 2)                                            // 第三屏    

      

      function_ping3++;                                             // 数值闪烁加    

      if(function_ping3 == 4)   

        

        function_ping3 0;                                         // 清零    

        function_flag 0;                                          // 功能标志位清零    

        

      change_num 40;                                              // 换屏计数器    

      

    

  if((key_code == 0x02) && (function_flag == 1))                    // 加法    

     

    clock_flag 2;                                                 // 关闭闹钟       

    if(function_ping2 == 1)                                         // 秒闪烁    

      

      sec++;                                                        // 秒加    

      if(sec == 60)                                                 // 秒是否等于60    

        sec 0;                                                    // 秒数清零    

      

    if(function_ping2 == 2)                                         // 分闪烁    

      

      min++;                                                        // 分加    

      if(min == 60)                                                 // 分是否等于60    

        min 0;                                                    // 分清零     

      

    if(function_ping2 == 3)                                         // 小时闪烁    

      

      hour++;                                                       // 小时加    

      if(hour == 24)                                                // 小时是否等于24    

        hour 0;                                                   // 小时清零    

      

    if(function_ping1 == 1)                                         // 日闪烁    

      

      day++;                                                        // 日加加    

      if(day tian)                                                // 日是否大于天    

        day 1;                                                    // 日等于1    

      

    if(function_ping1 == 2)                                         // 月闪烁    

      

      month++;                                                      // 月加加     

      tian tianshu[month];    

      if(day tian)   

        

        tian_flag 1;   

        

      else   

        tian_flag 0;   

      if(month == 13)                                               // 月是否等于13    

        month 1;                                                  // 月等于1    

      

    if(function_ping1 == 3)                                         // 年闪烁    

            

      year++;                                                       // 年加加    

      if((year%4 != 0)||(year0 != 0) || (year@0 == 0))   

        

       tian tianshu[month];    

       if(day tian)   

         

        tian_flag 1;   

            

      else    

        tian_flag 0;   

        

      if(year == 2100)                                              // 年是否等于2100    

        year 2000;                                                // 年到2000    

       

    if(function_ping3 == 1)                                         // 闹钟秒闪烁    

      

      nao_sec++;                                                    // 闹钟秒加加    

      if(nao_sec == 60)                                             // 闹钟秒是否等于60   

        nao_sec 0;                                                // 闹钟秒清零    

      

    if(function_ping3 == 2)                                         // 闹钟分闪烁    

      

      nao_min++;                                                    // 闹钟分加加    

      if(nao_min == 60)                                             // 闹钟分是否等于60   

        nao_min 0;                                                // 闹钟分清零    

      

    if(function_ping3 == 3)                                         // 闹钟小时闪烁    

      

      nao_hour++;                                                   // 闹钟小时加加    

      if(nao_hour == 24)                                            // 闹钟小时是否等于24    

        nao_hour 0;                                               // 闹钟小时清零    

        

    [page]

  if((key_code == 0x04) && (function_flag == 1))                    // 减法    

    

    clock_flag 2;                                                 // 清除闹钟标志位    

    if(function_ping2 == 1)                                            

       

      sec--;                                                        // 秒减减    

      if(sec == 0xff)                                               // 秒是否等于0     

        sec 59;                                                   // 秒等于60                                                                   

      

    if(function_ping2 == 2)                                            

      

      min--;                                                        // 分减减    

      if(min == 0xff)                                                  // 分是否等于0    

        min 59;                                                   // 分等于60                                                               

      

    if(function_ping2 == 3)                                            

      

      hour--;                                                       // 小时减减    

      if(hour == 0xff)                                                 // 小时是否等于0   

        hour 23;                                                  // 小时等于24                                                                

      

    if(function_ping1 == 1)   

      

      day--;                                                        // 天减减    

      if(day == 0)                                                  // 天是否等于0     

        day tian;                                                 // 天等于30/31/28/29                                                                 

      

    if(function_ping1 == 2)                                            

      

      month--;                                                      // 月减减    

      if(month == 0)                                                // 月是否等于0    

        month 12;                                                 // 月等于13    

      tian tianshu[month];     

      if(day tian)   

        tian_flag 1;   

      else    

        tian_flag 0;   

      

    if(function_ping1 == 3)    

       

      year--;                                                       // 年减减    

      if(year ==1999)                                               // 年是否等于1999    

        year 2100;                                                // 年等于2100     

      if((year%4 != 0)||(year0 != 0) || (year@0 == 0))   

        

       tian tianshu[month];    

       if(day tian)   

         

        tian_flag 1;   

            

      else    

        tian_flag 0;   

        

        

    if(function_ping3 == 1)                                           

        

      nao_sec--;                                                    // 闹钟秒减减    

      if(nao_sec == 0xff)                                              // 闹钟秒是否等于0    

        nao_sec 59;                                               // 闹钟秒等于60                                                               

      

    if(function_ping3 == 2)    

      

      nao_min--;                                                    // 闹钟分减减    

      if(nao_min == 0xff)                                              // 闹钟分是否等于0    

        nao_min 59;                                               // 闹钟分等于60                                                              

      

    if(function_ping3 == 3)    

      

      nao_hour--;                                                   // 闹钟小时减减    

      if(nao_hour == 0xff)                                             // 闹钟小时是否等于0    

        nao_hour 23;                                              // 闹钟小时等于24                                                             

      

    

  if((key_code == 0x02) && (function_flag == 0))                    // 没有功能键按下时   

    

    clock_flag 2;                                                 // 清除闹钟标志位    

    flag 1;                                                       // 换屏标志位被按下   

    if(num_flag == 1)                                               // 换屏位1    

     ping_flag 1;   

    if(num_flag == 2)                                               // 换屏位2    

     ping_flag 2;   

    if(num_flag == 3)                                               // 换屏位3    

     ping_flag 3;   

    

  if((key_code == 0x04) && (function_flag == 0))                       

    

    clock_flag 2;                                                 // 清除闹钟标志位    

    

  key_code 0;                                                     // 键值清零    

  

   

void leap_year(void)   

  

    tian tianshu[month];                                          // 读出每月天数表    

    if(day  tian)   

      tian_flag 0;   

    if(month == 2)   

      

      if((year%4 == 0)&&(year0 != 0) || (year@0 == 0))         // 判断是否是闰年    

         

         tian 29;                                                // 闰年2月天数修正    

         

       else   

         

         tian 28;                                                // 闰年2月天数修正    

         

      

  

   

void rtc()   

   

  if(++sec  60)                                                    // 秒加一    

    return;   

  sec 0;   

  if(++min  60)                                                    // 分加一    

    return;   

  min 0;   

  if(++hour  24)                                                   // 小时加一    

    return;   

  hour 0;   

  if(++day tian)                                                 // 天数加一    

    return;   

  day 1;                                                          // 月加一          

  if(++month 12)   

    return;   

   month 1;   

  if(++year  2100)                                                 // 年加一    

    return;   

  year 2000;      

  

   

void rtc_show(void)   

  

  if((function_ping1 != 0) && (function_ping2 == 0) && (function_ping3 == 0))   

    

    change_ping 0;                                                // 第一屏    

    

  else if((function_ping1 == 0) && (function_ping2 != 0) && (function_ping3 == 0))   

    

    change_ping 1;                                                // 第二屏    

    

  else if((function_ping1 == 0) && (function_ping2 == 0) && (function_ping3 != 0))   

    

    change_ping 2;                                                // 第三屏     

    

  if(change_ping == 1)   

    

    if(function_ping2 == 0)                                         // 正常显示    

      

      LCDMEM[0] digit[sec];    

      LCDMEM[1] digit[sec/10];    

      LCDMEM[2] digit[min];   

      LCDMEM[3] digit[min/10];        

      LCDMEM[4] digit[hour];   

      LCDMEM[5] digit[hour/10];   

      

    if(function_ping2 == 1)                                         // 秒闪烁    

      

      if(twinkle_num == 0)                                          // 闪烁标志位    

        

        LCDMEM[0] digit[sec];   

        LCDMEM[1] digit[sec/10];    

        

      else   

        

        LCDMEM[0] 0;   

        LCDMEM[1] 0;   

        

      LCDMEM[2] digit[min];   

      LCDMEM[3] digit[min/10];   

      LCDMEM[4] digit[hour];   

      LCDMEM[5] digit[hour/10];      

      

    if(function_ping2 == 2)                                         // 分闪烁    

      

      if(twinkle_num == 0)   

        

        LCDMEM[2] digit[min];   

        LCDMEM[3] digit[min/10];   

        

      else   

        

        LCDMEM[2] 0;   

        LCDMEM[3] 0;   

        

      LCDMEM[0] digit[sec];   

      LCDMEM[1] digit[sec/10];   

      LCDMEM[4] digit[hour];   

      LCDMEM[5] digit[hour/10];   

      

    if(function_ping2 == 3)                                         // 小时闪烁    

      

      if(twinkle_num == 0)                                                   

        

        LCDMEM[4] digit[hour];   

        LCDMEM[5] digit[hour/10];    

        

      else                                                             

        

        LCDMEM[4] 0;   

        LCDMEM[5] 0;   

        

      LCDMEM[0] digit[sec];   

      LCDMEM[1] digit[sec/10];   

      LCDMEM[2] digit[min];   

      LCDMEM[3] digit[min/10];   

      

    

  if(change_ping == 0)   

    

    if(function_ping1 == 0)                                         // 正常显示    

      

      LCDMEM[0] digit[(day)];   

      LCDMEM[1] digit[(day)/10];        

      LCDMEM[2] digit[(month)];   

      LCDMEM[3] digit[(month)/10];      

      LCDMEM[4] digit[year];                       

      LCDMEM[5] digit[(year/10)];    

      

    if(function_ping1 == 1)                                          // 天闪烁    

      

      if(twinkle_num == 0)   

        

        LCDMEM[0] digit[day];   

        LCDMEM[1] digit[day/10];    

        

      else   

        

        LCDMEM[0] 0;   

        LCDMEM[1] 0;   

        

      LCDMEM[2] digit[(month)];   

      LCDMEM[3] digit[(month)/10];      

      LCDMEM[4] digit[year];                       

      LCDMEM[5] digit[(year/10)];    

      

    if(function_ping1 == 2)                                          // 月闪烁    

      

      if(twinkle_num == 0)   

        

        LCDMEM[2] digit[(month)];   

        LCDMEM[3] digit[(month)/10];    

        

      else   

        

        LCDMEM[2] 0;   

        LCDMEM[3] 0;   

        

      LCDMEM[0] digit[day];   

      LCDMEM[1] digit[day/10];   

      LCDMEM[4] digit[year];                       

      LCDMEM[5] digit[(year/10)];   

      

    if(function_ping1 == 3)                                         // 年闪烁    

      

      if(twinkle_num == 0)   

        

        LCDMEM[4] digit[year];                       

        LCDMEM[5] digit[(year/10)];   

        

      else   

        

        LCDMEM[4] 0;                       

        LCDMEM[5] 0;    

        

      LCDMEM[0] digit[(day)];   

      LCDMEM[1] digit[(day)/10];        

      LCDMEM[2] digit[(month)];   

      LCDMEM[3] digit[(month)/10];    

      

    [page]

  if(change_ping == 2)   

    

    if(function_ping3 == 0)                                         // 正常显示    

      

      LCDMEM[0] digit[nao_sec];   

      LCDMEM[1] digit[nao_sec/10];        

      LCDMEM[2] digit[nao_min];   

      LCDMEM[3] digit[nao_min/10];      

      LCDMEM[4] digit[nao_hour];                       

      LCDMEM[5] digit[nao_hour/10];    

      

    if(function_ping3 == 1)                                        // 闹钟秒闪烁    

      

      if(twinkle_num == 0)   

        

        LCDMEM[0] digit[nao_sec];   

        LCDMEM[1] digit[nao_sec/10];    

        

      else   

        

        LCDMEM[0] 0;   

        LCDMEM[1] 0;   

        

      LCDMEM[2] digit[nao_min];   

      LCDMEM[3] digit[nao_min/10];      

      LCDMEM[4] digit[nao_hour];                       

      LCDMEM[5] digit[nao_hour/10];    

      

    if(function_ping3 == 2)                                        // 闹钟分闪烁    

      

      if(twinkle_num == 0)   

        

        LCDMEM[2] digit[nao_min];   

        LCDMEM[3] digit[nao_min/10];    

        

      else   

        

        LCDMEM[2] 0;   

        LCDMEM[3] 0;   

        

      LCDMEM[0] digit[nao_sec];   

      LCDMEM[1] digit[nao_sec/10];   

      LCDMEM[4] digit[nao_hour];                       

      LCDMEM[5] digit[nao_hour/10];   

      

    if(function_ping3 == 3)                                       // 闹钟小时闪烁    

      

      if(twinkle_num == 0)   

        

        LCDMEM[4] digit[nao_hour];                       

        LCDMEM[5] digit[nao_hour/10];   

        

      else   

        

        LCDMEM[4] 0;                       

        LCDMEM[5] 0;    

        

      LCDMEM[0] digit[nao_sec];   

      LCDMEM[1] digit[nao_sec/10];        

      LCDMEM[2] digit[nao_min];   

      LCDMEM[3] digit[nao_min/10];    

      

    

  

     

#pragma vector=BASICTIMER_VECTOR    

__interrupt void basic_timer (void)   

    

  if(clock_flag == 1)                                              // 闹钟存在    

    P1OUT ^= BIT0;                                                 // LED闪烁    

  if(clock_flag == 2)                                              // 闹钟清除    

    P1OUT &= ~BIT0;                                                // 关闭LED     

  cnt++;                                                           // 1s计数器加    

  if(cnt == 4)                                                     // 是否等于4    

    

    rtc();                                                         // 秒加一    

    cnt 0;                                                       // 清零    

     

  change_num++;                                                    // 换屏计数器    

  twinkle_num ~twinkle_num;                                      // 闪烁标志位     

  if(change_num == 60)                                             // 屏幕切换计数器到时复位    

    

    change_num 0;                                                //     

    

  if(((change_num 0) && (change_num  20) || (change_num == 0)) || ((ping_flag == 1) && (flag == 1)))   

    

    if((ping_flag == 1) && (flag == 1))                            // 按键时在第一屏    

      

      change_num 20;                                             // 切换到第二屏    

      flag 0;                                                    // 按键标志位清零    

      

    change_ping 0;                                               // 第一屏    

    num_flag 1;                                                  // 屏切换标志位1    

    

  if(((change_num 20) && (change_num  40) || (change_num == 20)) || ((ping_flag == 2) && (flag == 1)))   

    

    if((ping_flag == 2) && (flag == 1))                            // 按键时在第二屏    

      

      change_num 40;                                             // 切换到第三屏    

      flag 0;   

      

    change_ping 1;                                               // 第二屏    

    num_flag 2;                                                  // 屏切换标志位2    

    

  if(((change_num 40) && (change_num  60) || (change_num == 40)) || ((ping_flag == 3) && (flag == 1)))    

    

    if((ping_flag == 3) && (flag == 1))                            // 按键时在第二屏    

      

      change_num 0;                                              // 切换到第1屏    

      flag 0;   

      

    change_ping 2;                                               // 第三屏    

    num_flag 3;                                                  // 屏切换标志位3    

      

关键字:MSP430F449  单片机  RTC时钟 引用地址:MSP430F449单片机RTC时钟C语言程序(带闹钟)

上一篇:MSP430单片机的PCF8563时钟芯片C语言驱动程序
下一篇:msp430单片机的ds18b20测温度c程序

推荐阅读最新更新时间:2024-03-16 14:30

如何用低成本ARM Cortex-M微控制器让家电变得更安全
自2007年起,家电厂商的所有新设计必须遵守IEC60335安全标准。为确保家电设备安全可靠,特别是设备故障不能威胁用户的人身安全,这套新标准涉及十分广泛的内容,从机械系统到嵌入电子元器件均有明确规定。 电子部分参照另一个标准,即适用于各种应用领域的IEC60730自动电子控制标准。对于嵌入式系统开发人员,附件H对于嵌入式系统开发人员尤为重要,因为该附件是关于可编程器件。白色家电通常使用多个微控制器:一个微控制器负责管理控制台,另一个管理阀门和电机控制。 根据设备故障导致的危险程度,该标准将软件分为A、B、C三类。如果家电安全不依靠软件,则该家电属于A类,如室内温控器或照明控制器。相反,如果软件用于防止安全隐患,如电子点火燃气
[单片机]
如何用低成本ARM Cortex-M<font color='red'>微控制器</font>让家电变得更安全
采用Cortex-M3单片机设计的WiFi物联网小车
  WiFi物联网小车设计方案,采用电脑上位机软件通过无线WiFi 控制小车的运动,采集小车的信息。与传统的“智能小车”相比,主要特点在于使用32 位高性能单片机控制、互联网通信机制和电脑上位机软件控制。此方案融合了电脑软件、网络通信、图像处理、图形显示、运动控制、速度采集和温度采集等技术,具有“物联网”的相关特点。传统的小车控制大多使用红外通信,使用遥控器进行控制,不但受到距离的限制,而且远没有电脑软件直观美观。互联网通信使小车具备远程控制的能力,这是红外通信望尘莫及的。此外,本方案小车控制芯片采用Cortex-M3单片机,该单片机具有极丰富的外设,这给小车以后功能升级和扩展奠定了基础。   1 总体设计方案   WiFi 物联
[电源管理]
采用Cortex-M3<font color='red'>单片机</font>设计的WiFi物联网小车
基于单片机AT89C51的时间/位移换向控制器设计
引言 在实际生产过程中,常常要用到具有自动换向功能的控制部件,如机械加工中的往返运行(位移),直流电源的正反向输出,电动机的正反转运行等现象,都是当正向(或反向)运行到一定时间或一定位置时,自动换为反向(或正向)运行,周而复始的过程。实现这一过程的自动化,就是设计一套控制电路,再配以位移传感器或时间继电器。目前市场现有的时间继电器虽然可以用多个组合来满足一些使用场合的要求,但仍存在着重复计时误差大,稳定可靠运行性不高,使用不方便灵活等问题。为此,笔者研发了以单片机为核心组成的时间/位移换向控制器SWHX-1,该系统具有成本低等特点,可完全且克服以上不足。 电路组成及工作原理 SWHX-1的内部电路如图1所示。该系统分为输入输
[应用]
基于51单片机ADC0808自动数字电压表仿真数码管显示
硬件设计 该设计是基于51单片机,ADC采用TI公司的ADC0808,自动数字电压测量表,显示器采用4位数码管,测量范围为0.5~10V,精度约为0.02。 仿真图如下: 程序源码: #include reg52.h unsigned char code dispbitcode ={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; unsigned char dispbuf ; unsigned int i; unsigned int j; unsigned int getdata; unsigned int temp; unsigned int temp1;
[单片机]
基于51<font color='red'>单片机</font>ADC0808自动数字电压表仿真数码管显示
51单片机外部中断产生条件
最近在做单片机外部中断实验的时候以为忘记产生中断的条件,于是查找了大学时代的教材和一些关于单片机的书籍,结果发现里面都没有相关的介绍。接着我有在AT89S52的中英文手册中查找了相关内容也没有找到相关的说明。最后不得已百度了一下,找到了答案如下: 5个中断源的符号、名称及产生的条件如下。 INT0:外部中断0,由P3.2端口线引入,低电平或下降沿引起。 INT1:外部中断1,由P3.3端口线引入,低电平或下降沿引起。 T0:定时器/计数器0中断,由T0计满回零引起。 T1:定时器/计数器l中断,由T1计满回零引起。 TI/RI:串行I/O中断,串行端口完成一帧字符发送/接收后引起。
[单片机]
51单片机实验16:A/D模数转换(XPT2046)
关于A/D模数转换以及XPT2046芯片的内容请参考:https://blog.csdn.net/cax1165/article/details/87024388 #include reg52.h #include XPT2046.h sbit LSA=P2^2; sbit LSB=P2^3; sbit LSC=P2^4; uc code x ={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; uc dig ; void delay(uc x) { uc i,j; for(i=1;i =x;i++) for(j=1;j =110;j++); } v
[单片机]
基于μPD78F0034单片机的出租车计费器的设计与实现
    介绍了基于μPD78F0034单片机和模块式结构的出租车计费器的硬件和软件设计方法,讨论了μPD78F0034单片机的主要特点;介绍了该单片机和PC机串行通信的硬件连接方法;同时给出了采用单、双信号防作弊技术来防止计费器作弊的具体实现方法。   随着出租车行业的发展,对出租车计费器的要求也越来越高,用户不仅要求计费器性能稳定,计费准确,有防作弊功能;同时还要求其具有车票资料打印、IC卡付费、语音报话、和电脑串行通信等功能。通常,设计出租车计费器面临以下三方面的问题:   (1)不同国家和地区的计费方式存在差异。有些地区有夜间收费及郊区收费等,而有些地区则无夜间收费和郊区收费;即使同一地区,不同车型的出租车,其计费方
[嵌入式]
通过利用C8051F020单片机实现立体声信号相位差电平差测试仪的设计
将LR立体声信号经频谱分析、整形及占空比检测电路进行处理,采用过零鉴相法,通过测矩形波占空比,实现相位差的测试。将LR信号用AD736专用芯片实现AC/DC转换,通过单片机编程,得到LR电平差。 在立体声播音或放音时,如果左右声道信号存在相位差和电平差,对播音或放音质量将会产生一定影响,出现声像漂移、音量减小、噪音增大和失真等故障现象。左右声道相位差电平差越大,音质也越差,严重时还会造成无音故障。 为此文中设计了立体声信号相位差电平差测试仪,只有准确测出相位差电平差,再用补偿电路进行修正,才能保证播音或放音质量,更好地满足人们欣赏到音质优美的广播或音乐的需要。 1 设计方案 如图1所示,是立体声信号相位差电平差测试仪原理方
[单片机]
通过利用C8051F020<font color='red'>单片机</font>实现立体声信号相位差电平差测试仪的设计
小广播
添点儿料...
无论热点新闻、行业分析、技术干货……
设计资源 培训 开发板 精华推荐

最新单片机文章
何立民专栏 单片机及嵌入式宝典

北京航空航天大学教授,20余年来致力于单片机与嵌入式系统推广工作。

换一换 更多 相关热搜器件
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved