AnsweredAssumed Answered


Question asked by jibo on Jan 1, 2014

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.







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


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




        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;           // 开接收中断