首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

请教一个关于MC9S12XEP100的小灯翻转程序

请教一个关于MC9S12XEP100的小灯翻转程序

请教MC9S12XEP100程序:定时500ms实现PORTB_PB0管脚的小灯翻转,我在按下面的程序调试后发现小灯只亮,而没有实时翻转,请问是什么原因呢?不胜感激!

#include <hidef.h>      /* common defines and macros */
#include <MC9S12XEP100.h>     /* derivative information */
#pragma LINK_INFO DERIVATIVE "mc9s12xep100"
#include "CRG_Init.h"
#include "PIT_Init.h"
unsigned char Flag;
void Delay(unsigned int Time)
{
    unsigned char i;
    for(i=0; i<125; i++)
        for( ; Time>0; Time--);
}
void main(void) {
  /* put your own code here */
  EnableInterrupts;
  DDRB=0xff;
  PORTB=0xff;
  
  for(;;) {
  
     if(Flag==1){
      
        Flag=0;
        Delay(50000);
        PORTB_PB0=~PORTB_PB0;
     }
  } /* wait forever */
  /* please make sure that you never leave this function */
}
#pragma  CODE_SEG   NON_BANKED
interrupt void PIT0_Timeout()    //interrupt function when Time0 out 20ms
{
   PITTF &= 0x01;           // Clear the timer0-out flag  
   Flag = 1;
}
返回列表