DZ60 MSCAN PROBLEM

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

DZ60 MSCAN PROBLEM

495 Views
admin
Specialist II

Happy new year everybody! Now I have two questions to ask. First, I am using DZ60 (48 pins) MCU. A problem has been encountered when using MSCAN. In lookback self test mode, the initialization of MSCAN can be completed, but when in normal work mode, the initialiation of the MSCAN will stop in "while(!(CANCTL0_SYNCH))", how to resolve it ,this has confuse me for several days. The second problem when a new project of DZ60 is built using  CodeWarrior, the header file and so on are all for 64 pins MCU, like this "/* Based on CPU DB MC9S08DZ60_64, version 3.00.001 (RegistersPrg V2.23) */". If I am using 32 pins or 48 pins MCU, the header files and so on needed to be changed? and how to changed. Thanks very much.

 

Flowing is the proble described in chinese and the code of initialization for the MSCAN.

 

大家好,2014年第一天,先祝大家新年快乐,新的一年事事顺心。

    有两个问题请教大家:1)我现在用DZ60,48脚单片机做了个板子,现在CAN通讯部分,MSCAN的初始化位置如果设置成环回自测模式,可以实现数据的收发,但如果设成正常模式,则在等待时钟同步处,停住,不往下运行了。大家看是怎么回事呢?程序代码如下。2)通过CodeWarrier建立一个新的工程,选择DZ60,生成的工程中,包含的头文件等都是64脚这种情况的,如果我用DZ60的32或48脚单片机,头文件需不需要修改,怎样修改,谢谢大家。

 

MSCAN初始化代码如下:

 

if(CANCTL1_CANE == 0)            // 判断CAN模块是否启动,当前未启动系统初始化

    {

        CANCTL1_CANE = 1;            // 系统初始化后CAN模块默认进入初始化状态     

    }

    else

    {

        CANCTL0_SLPRQ = 1;           // CAN模块已经运行  还要确保MSCAN没有等待发送的队列

        while(CANCTL1_SLPAK == 0);   // 将CAN模块置入睡眠模式

        CANCTL0_INITRQ = 1;          // 要求进入初始化状态

        while(0 == CANCTL1_INITAK);  // 这句话保证将CAN模块置入初始化模式

    }      

 

  

    CANBTR0 = 0b10000001;            //CANBTR0 = 0b1000 0001;          //同步跳转宽度:3Tq时钟周期;预分频器值是2

    CANBTR1 = 0b01001001;            //CANBTR1 = 0b0100 1001;          //时间段1是6个tq时钟周期,时间段2是3个tq时钟周期   

    //每位一个样本  时间段2是5个tq时钟周期      时间段1是10个tq时钟周期     //波特率为250K   

     

    CANIDMR0 = 0xFF;

    CANIDMR1 = 0xFF;

    CANIDMR2 = 0xFF;

    CANIDMR3 = 0xFF;

 

    CANIDAC=0X0F;                //使用了2组32位接受滤波器   

 

 

    //CANCTL1 = 0b11100000;        //使能MSCAN模块,时钟是总线时钟,环回自测模式

    CANCTL1 = 0b11000000;        //使能MSCAN模块,时钟是总线时钟,正常工作模式

    //CANCTL1 = 0b10000000;        //使能MSCAN模块,时钟是振荡时钟,正常工作模式

 

  

    CANCTL0 = 0x00;              //返回一般模式运行    

  

    while(CANCTL1_INITAK);       // 等待回到一般运行模式                                

    while(!(CANCTL0_SYNCH));     // 等待总线时钟同步     

  

    CANRIER_RXFIE = 1;           // 开接收中断

Labels (1)
Tags (1)
0 Kudos
0 Replies