打印
[ZLG-MCU]

奇怪的lpc9401的仿真问题,进入不了中断,希望大家出出招

[复制链接]
1780|5
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
yzggy|  楼主 | 2007-2-5 10:13 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
     近来用的lpc9401芯片,仿真器用的是周工的tks-936, 仿真环境用的是keil c, 不知为啥原因,就是进入不了rtc中断, 连tmr0,tmr1中断也进如不了,希望能有用过的朋友指点一,二,不胜感激,期待中,
    
TRIM=TRIM&0x3f;                //内部时钟使用出厂预设值,p3.0脚位不输
                                                                     
TMOD=0X44;                //将tmr0,tmr1配置为计时模式并打开tmr0  
TAMOD=0X00;                //将tmr0,tmr1配置为计时模式            
TCON=0X50;                                                      
                                                                     
AUXR1|=0X80;                                                         
//                                                                   
PCON=0X00;                //刚上电不将其用在省电模式             
PCONA=0X00;                //将iic,rtc上电                        
DIVM=0X50;                                                           
//                                                                   
//                                                                   
//                                                                   
//                                                                   
//                                                                   
RSTSRC=0X00;                                                         
WDCON=0XE0;                                                          
//                                                                   
RTCH=0X0f;                                                           
RTCL=0Xff;                                                           
                                                                     
RTCCON=0X63;            //配置rtc时钟,打开,                  
                                                                     
IEN0=0XC0;                //只将time0,time1,rtc中断打开          
IEN1=0X01;                //将其他所有中断关闭 ,但要打开iic中断  
IP0=0XFF;                                                            
IP0H=0XFF;                                                           
IP1=0XFF;                                                            
IP1H=0XFF;                                                           

上面是写的各个配置,请帮忙看看有没问题? 谢谢!

相关帖子

沙发
雁舞白沙| | 2007-2-5 11:29 | 只看该作者

我的程序

//-----***-CPU寄存器以及外围接口初始化-***-----//
void InitSeries(void)
{
     PCON =    0x20;             //SMOD1=0;SMOD0=0;通讯速率不加倍,SCON.7作为UART的SM0位                                //禁止掉电检测
     SCON =    0xd0;             //串口工作在模式3,禁止串口接收
     SSTAT=    0x60;             //串口工作在普通模式
     BRGCON |= 0x02;             //选择波特率发生器用于产生UART的波特率,禁止使能
     BRGR1=0x27;                 //装载高字节
     BRGR0=0x00;                 //装载低字节
     BRGCON |= 0x01;             //使能拨特率发生器
     ESR=1;                         //使能串口中断
}
void InitCpuIo(void)
{
     P0M1=0x00;
     P0M2=0x00;                     //
     P1M1=0xec;//==>1110 1100
     P1M2=0x0c;//==>0000 1100
     P2M1=0x40;                     //设置P26为开漏
     P2M2=0x40;
}
void InitWDT(void)
{
     WDL=255;
     WDCON=0xE5;
     WFEED1=0xA5;                  //喂狗
     WFEED2=0x5A;
}
void InitINT0(void)
{
     IT0=0;                        //外部中断0采用低边沿触发中断
     IP0H=0x01;
     IP0=0x01;
     EX0=1;                        //开启中断
}
void Initkey(void)                 //初始化键盘中断
{
    KBPATN=0x3F;                   //
    KBCON=0; 
    KBMASK=0xc0;                   //设置P0.7&P0.6为中断源
    EKBI=1;
}
void InitPWM()                     //使用外部12M振荡器时:CCU频率=((3579545/2)/6)*16=16000000MHz
{
    TOR2H=0x03;                    //定时器重装值=CCU频率/红外线载频=16000000/38000=421=0x1a5
    TOR2L=0x4a;
    OCRAH=0x01;                    //(OCRAH:OCRAL)=(TOR2H:TOR2L)/2,PWM的占空比为50%
    OCRAL=0xa5;
    TCR21=0x85;                    //PLL预分频为5+1
    CCCRA=1;                       //非反相的PWM比较匹配时置位,在CCU定时器向下溢出时清0
    PLLEN=1;                       //启动PLL
    HwPwm=1;
    while(PLLEN==0);
    TCR20=0x82;                    // 设置输出模式,非反相PWM
}
//-----***-时钟发生器运行初始化-***-----//
void InitRTC(void)
{
    WDT();
    IicByteWrite(0x64,0xE0,0x23);//秒输出,24小时
    Delay(500);
    IicByteWrite(0x64,0xF0,0x20);//清除本次状态,开始下次检测
    Delay(500);
}
//-----***-液晶显示驱动器初始化-***-----//

void InitLcd(void)
{
    WDT();
    LcdSendCommand(0x01);//
    LcdSendCommand(0x29);//
    LcdSendCommand(0x18);//
    LcdSendCommand(0x03);//                                
}
void InitCpu(void)
{
    DIVM=0x00;
    WDT();
    InitWDT();
    InitCpuIo();   
    InitSeries();    
    InitINT0();
    Initkey();
    InitPWM();
}

使用特权

评论回复
板凳
yzggy|  楼主 | 2007-2-5 14:47 | 只看该作者

白沙兄可否留下详细的联系方式,好进一步请教

使用特权

评论回复
地板
zlgmcu| | 2007-2-5 22:07 | 只看该作者

TKS936的客户可以发email到tks@zlgmcu.com索取范例.

另:非常感谢白沙的友情帮助!

使用特权

评论回复
5
yzggy|  楼主 | 2007-2-19 02:29 | 只看该作者

谢谢

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

5

主题

9

帖子

0

粉丝