This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Re: TMS570 CAN Interrupt

Other Parts Discussed in Thread: HALCOGEN, CCSTUDIO

Hi,

 

I´m using the TMS570 MCU development Kit, and I´m trying to do a simple CAN program.

 

First of all I have created a program using HALCoGen and then I have taken the attached DCAN program of this page.

 

I’ve modified all the registers so that it can compile with the TMS570.

 

So, I’ve initialized the module with canInit(), and the rest of the program it´s the same of the attached program.

 

But nothing happens, I can´t transmit either receive messages, I don’t know what I´m doing wrong. The only difference is that I don’t use this functions:

 

                VIM_RAM_Init();

                swi_enable_irq();

                dcan_enable_int();

 

I don´t know where can I find the first two functions, and the 3rd , if its only for enabling the interrupts, I think I do that in the function canInit.

 

When I run the program, it always stops in the while for detecting the newdat.

 

Are these functions necessary? 

 

I can send the main program with all the changes I did if necessary.

 

Thanks in advance for your help.

 

David

  • Hi David,

     

    Are you trying to comminicate with the other CAN on the same Micro ?

     

    Regards

    Pratip

  • David,

    1881.TMS570MDK_CAN12_Loopback.zip

    Attached please find the example project for DCAN communication between DCAN1 and DCAN2. If you want to test DCAN1 and DCAN3, please replace canREG2 with canREG3 in main function. I tested this project on TMS570 MDK. please wire DCAN1 H to DCAN2 H, and DCAN1 L to DCAN2 L to do DCAN1 and DCAN2 communication test.

    The CMD file is configured to execute code in RAM rather than flash.

    Regards,

    QJ

  • Hi QJ,

    Thanks for your program, but I haven´t been able to prove it.

    I imported your project to ccstudio but when I run it stopped on the Prefetch file. It seems no to enter to the main program.

    I suppose the problem is that I still executed in Flash and no in RAM. How can I change that configuration? I have read different posts on the forum but when I compile always appears some error.

    Can you help me? What I need to run the program on RAM?

    David

  • Hi David,

    5126.TMS570MDK_CAN12_Loopback.zip

    This is the project to run the code in RAM

    Two places I changed for running the code in RAM:

    1. CMD file:
        .bss     : {} > FLASH1         //RAM
        .data    : {} > FLASH1         //RAM
    2. stack pointers: (in sys_core.asm) (0x08000000 --> 0x00000000)
        ser:    .word 0x00000000+0x00000200
        svc:    .word 0x00000000+0x00000200+0x00001200
        fiq:    .word 0x00000000+0x00000200+0x00001200+0x00000200
        irq:    .word 0x00000000+0x00000200+0x00001200+0x00000200+0x00000400
        abort:  .word 0x00000000+0x00000200+0x00001200+0x00000200+0x00000400+0x00000100
        undef:  .word 0x00000000+0x00000200+0x00001200+0x00000200+0x00000400+0x00000100+0x00000100
    3. After connect to CCS4, run the scripts:
       Target RAM to 0x00
       Memory map at 0x00

    Regards,

    QJ

  • Hi QJ,

    I don´t know what I´m doing wrong. I´m going to explain what I have done:

    1. With the first project attached.

    - Download

    - Create a project importing from the correct folder.

    - Add the XDS100V2.ccxml file

    - Build

    - Debug

    In the first try I don´t run the scripts (target RAM to 0x00 and memory map to 0x00)

    Well, on the watch window I enter the variables tx_data and rx_data but I haven't seen anything, it seems that doesn´t enter into the main program, and if I go step by step it jumps to sys_intvecs.asm.  

    Finally I run the scripts with any result.

    1.1   I change the .cmd file , .bss and .data. Both to RAM. Nothing. 

    2. With the 2nd project attached the same: download, import de project, add ccxml file build and debug.

    With and without running the scripts I haven't seen any communication.

     

    So I have proved both projects, both in Flash and Ram with any results.

    I´m using the TMS570LS20216ZWT, TMDX570LS20SMDK development kit, CCS Version: 4.1.1.00014 and I only add to the projects the .ccsml file.

    Why can´t I see any communication?

  • Hi David,

    Can you please givel me your phone #? I'd like to solve the problem on phone. It is quicker.

    Regards,

    QJ

  • Hi QJ Wang,

    The phone is +34 943 71 24 00. Be aware that I work on Spain, please call me in the afternoon at 5:30PM.

    Ask for David Bea.

    David

  • Hi Qj,

    I'm using Tms570lm20216, in this i'm trying to transmit 8 msgs using can 1 and trying to recieve those msgs using can2..

    it worked by using polling mode..but i'm trying in intruppt mode.. its not working plz suggest something..

     

    Thanks and Regards

    Vinod N.

     

  • Hi Vinod,

    Please make sure you have enabled the interrupt and defined the ISR:

    1. enable IRQ or FIQ ( I and F bit in CPSR register)

    2. enable CAN INT (canREG1/2->INTMUXx)

    3. configure INT priority, Mask (IRQ or FIQ,  vimREG->FIRQPR0/1/2, vimREG->REQMASKSET0/1/2)

    4. Assign the CAN ISR to the correct VIM channel (for example, can1HighLevelInterrupt,   /*16; CAN1 level0  */)

    I recommend you to use the HalCoGen to generate CCS project.

    Regards,

    QJ

  •  Hi QJ Wang, Thank you for your reply.

    As u said the Intrrupt is working but the problem what i'm facing is.

    1) if i continuously send msgs form can1 to can2 i'm not able to recive the msga in can2.

    2)sometimes the DLC is becoming 72.

    3) if i transmit only once from can1 even then the program is entering into the notification.

    i have attached both main.c and notification.c file plz find them and go through that.

    if there is anything wrong i have done plz let me know

    Thanks and Regards

    Vinod

     main.c

    #include "sys_common.h"
    #include "system.h"
    #include "sci.h"
    #include "can.h"


    uint8_t RX_data;

    extern void CanIntHandler(void);
    extern void sciDisplayText(sciBASE_t *sci, uint8_t *text,uint32_t length);


    #define D_SIZE1 10
    #define D_SIZE2 9
    #define D_SIZE3 9
    #define D_SIZE4 9
    #define D_SIZE5 9
    #define D_SIZE6 9
    #define D_SIZE7 9
    #define D_SIZE8 10

    #define T_SIZE1 10
    #define T_SIZE2 9
    #define T_SIZE3 9
    #define T_SIZE4 9
    #define T_SIZE5 9
    #define T_SIZE6 9
    #define T_SIZE7 9
    #define T_SIZE8 10

    uint8_t rx_data1[T_SIZE1] = {0};
    uint8_t rx_data2[T_SIZE2] = {0};
    uint8_t rx_data3[T_SIZE3] = {0};
    uint8_t rx_data4[T_SIZE4] = {0};
    uint8_t rx_data5[T_SIZE5] = {0};
    uint8_t rx_data6[T_SIZE6] = {0};
    uint8_t rx_data7[T_SIZE7] = {0};
    uint8_t rx_data8[T_SIZE8] = {0};

    uint8_t tx_data1[D_SIZE1] = {'\n','H','E','R','C','U','L','E','S','\0'};
    uint8_t tx_data2[D_SIZE2] = {'\n','T','M','S','5','7','0','R','\0'};
    uint8_t tx_data3[D_SIZE3] = {'\n','R','M','4','F','C','N','T','\0'};
    uint8_t tx_data4[D_SIZE4] = {'\n','L','E','D','D','I','S','P','\0'};
    uint8_t tx_data5[D_SIZE5] = {'\n','C','A','N','T','E','S','T','\0'};
    uint8_t tx_data6[D_SIZE6] = {'\n','I','N','T','R','U','P','P','\0'};
    uint8_t tx_data7[D_SIZE7] = {'\n','N','O','T','I','F','I','C','\0'};
    uint8_t tx_data8[D_SIZE8] = {'\n','C','C','S','T','U','D','I','O','\0'};

    void main(void)
    {
    _enable_IRQ();
    sciInit();
    canInit();
    sciDisplayText(sciREG1,"can test\n",10);


    while(1)
    {
    canTransmit(canREG1,canMESSAGE_BOX17,tx_data1);
    canTransmit(canREG1,canMESSAGE_BOX18,tx_data2);
    canTransmit(canREG1,canMESSAGE_BOX19,tx_data3);
    canTransmit(canREG1,canMESSAGE_BOX20,tx_data4);
    canTransmit(canREG1,canMESSAGE_BOX21,tx_data5);
    canTransmit(canREG1,canMESSAGE_BOX22,tx_data6);
    canTransmit(canREG1,canMESSAGE_BOX23,tx_data7);
    canTransmit(canREG1,canMESSAGE_BOX24,tx_data8);
    }
    }

    void CanIntHandler(void)
    {

    if(canIsRxMessageArrived(canREG2,canMESSAGE_BOX17))
    {
    sciDisplayText(sciREG1,"\ncanRXok1" ,T_SIZE1);
    canGetData(canREG2,canMESSAGE_BOX17,rx_data1);
    sciDisplayText(sciREG1,&rx_data1[0] ,T_SIZE1);
    }
    if(canIsRxMessageArrived(canREG2,canMESSAGE_BOX18))
    {
    sciDisplayText(sciREG1,"\ncanRXok2" ,T_SIZE2);
    canGetData(canREG2,canMESSAGE_BOX18,rx_data2);
    sciDisplayText(sciREG1,&rx_data2[0] ,T_SIZE2);
    }
    if(canIsRxMessageArrived(canREG2,canMESSAGE_BOX19))
    {
    sciDisplayText(sciREG1,"\ncanRXok3" ,T_SIZE3);
    canGetData(canREG2,canMESSAGE_BOX19,rx_data3);
    sciDisplayText(sciREG1,&rx_data3[0] ,T_SIZE3);
    }
    if(canIsRxMessageArrived(canREG2,canMESSAGE_BOX20))
    {
    sciDisplayText(sciREG1,"\ncanRXok4" ,T_SIZE4);
    canGetData(canREG2,canMESSAGE_BOX20,rx_data4);
    sciDisplayText(sciREG1,&rx_data4[0] ,T_SIZE4);
    }
    if(canIsRxMessageArrived(canREG2,canMESSAGE_BOX21))
    {
    sciDisplayText(sciREG1,"\ncanRXok5" ,T_SIZE5);
    canGetData(canREG2,canMESSAGE_BOX21,rx_data5);
    sciDisplayText(sciREG1,&rx_data5[0] ,T_SIZE5);
    }
    if(canIsRxMessageArrived(canREG2,canMESSAGE_BOX22))
    {
    sciDisplayText(sciREG1,"\ncanRXok6" ,T_SIZE6);
    canGetData(canREG2,canMESSAGE_BOX22,rx_data6);
    sciDisplayText(sciREG1,&rx_data6[0] ,T_SIZE6);
    }
    if(canIsRxMessageArrived(canREG2,canMESSAGE_BOX23))
    {
    sciDisplayText(sciREG1,"\ncanRXok7" ,T_SIZE7);
    canGetData(canREG2,canMESSAGE_BOX23,rx_data7);
    sciDisplayText(sciREG1,&rx_data7[0] ,T_SIZE7);
    }
    if(canIsRxMessageArrived(canREG2,canMESSAGE_BOX24))
    {
    sciDisplayText(sciREG1,"\ncanRXok8" ,T_SIZE8);
    canGetData(canREG2,canMESSAGE_BOX24,rx_data8);
    sciDisplayText(sciREG1,&rx_data8[0] ,T_SIZE8);
    }
    }

    void sciDisplayText(sciBASE_t *sci, uint8_t *text,uint32_t length)
    {
    while(length--)
    {
    while ((sci->FLR & 0x4) == 4); /* wait until sci is ready */
    sciSendByte(sci,*text++); /* send out text */
    };
    }

     

     

     

     

     

     notification.c

     

     

     void canMessageNotification(canBASE_t *node, uint32 messageBox)
    {
    sciDisplayText(sciREG1,"Notification\n" ,14);

    CanIntHandler();
    }

     Thanks and Regards

       Vinod

     

  • Vinod,

    Enclosed is my sample for CAN1 and CAN2 communication. It works well on RM48 HDK.

    3301.can.h


    Regards,

    QJ