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.

tms470 dcan baudrate configuration

Other Parts Discussed in Thread: HALCOGEN, TMS470MF06607

hi,

i am using the TMS470M HDK . for this controller the DCAN baudrate configurations all are done by the helcogen code generator.

i am transmit and receive the data at  500Kbps .   in the halcogen code generator , if i am try to generate the code at any other baudrate  (other than 500kbps) , like 125Kbps , 33.333Kbps,  83.333Kbps , 250Kbps, its showing the warning and error.

how can i generate the code in other baudrates.  

if i am try to gererate any other baudrates means, the halcogen code generator giving some values. i dont know its correct or not.

baudrates BRPE BRP SJW SYN PROPAGATION PHASE1 PHASE2
33.333Kbps 2 43 4 1 1 6 6
83.333Kbps 1 4 4 1 1 6 6
100Kbps 1 35 3 1 1 3 3
125Kbps 1 15 3 1 1 3 3
1 Mbps 0 7 1 1 7 1 1

qus 2 :   is this TMS470MF06607 microcontroller support the GMLAN (single wire CAN) , and FTCAN (Fault Tolerant CAN). because in my application i want the Single Wire CAN & Fault Tolerant CAN also . is it possible i can did those two CAN in this controller ???

regards

arun kumar 

  • The HALCoGen generator gives a warning when you type in the first digit of the baudrate (as 1K baud does not work using the HALCoGen generator). That warning can be ignored once you type in the entire desired baud rate. The values calculated for the baudrates in your table above are correct.

    My understanding is that GMLAN and FTCAN are physical implementations that only affect the CAN driver chip. With the proper CAN driver chip those protocols can be supported by the DCAN module on TMS470MF06607, but the SN65HVDA541 driver chips on the HDK support ISO-11898.
  • hi sir,

    what ever the values created by the HALCoGen code generator , that is working for different baudrates. but now i am facing one problem.
    for 100Kbps , and 125Kbps , my code is working properly.

    when i am configure my code 33.333Kbps & 83.333Kbps its not working properly.
    i attached my code in downside. in that program, first my code is run in 500Kbps. after that i configure my code for 33.333Kbps and 83.333Kbps

    in 500Kbps its transmit the data properly. but when i configure my code to 33.333Kbps and 83.333Kbps , its not transmit every time.
    in my code i am using the two for loop(). in that first for loop() at the last time [i=7 (at 8th time)] only its transmit only one time. before that its not transmit. in the 2nd for loop() , its transmit the last time [ i=2 ( at 3rd time ) ] .

    i dont know where the problem occur. can u please tell me the solution for this problem sir.



    PROGRAM:

    #include "sys_common.h"
    #include "system.h"

    #include "can.h"
    #include "esm.h"

    #define D_SIZE 8
    uint8 tx_data[D_SIZE] = {'H','E','R','C','U','L','E','S'};
    uint8 tx2_data[D_SIZE] = {'1','s','t','L','O','O','P'};
    uint8 tx1_data[D_SIZE] = {'T','I','G','E','R'};
    uint8 rx_data[D_SIZE] = {0};
    int i=0;

    void can_baud_33kbps(void); // checked (no working) at last time only working
    void can_baud_83kbps(void); // checked (no working) at last time only working
    void can_baud_100kbps(void); // checked (working)
    void can_baud_125kbps(void); // checked (working)

    void main(void)
    {

    canInit();
    canTransmit(canREG1, canMESSAGE_BOX2, tx_data);

    while(!canIsRxMessageArrived(canREG1, canMESSAGE_BOX1));
    canGetData(canREG1, canMESSAGE_BOX1, rx_data);

    if(rx_data[0] == 0x61)
    {
    can_baud_33kbps();
    can_baud_83kbps();

    }

    for(i=0;i<8;) // FOR LOOP 1
    {
    canTransmit(canREG1, canMESSAGE_BOX2, tx2_data);
    i++;
    }

    for(i=0;i<3;i++) // FOR LOOP 2
    {
    canTransmit(canREG1, canMESSAGE_BOX2, tx1_data);
    }

    canTransmit(canREG1, canMESSAGE_BOX2, tx_data);

    while(1);

    }




    void can_baud_33kbps(void)
    {


    canREG1->CTL = 0x00000000U
    | 0x00000000U
    | 0x00021443U | (1<<2) | (1<<3) ;

    /** - Clear all pending error flags and reset current status */
    canREG1->ES = canREG1->ES;

    /** - Assign interrupt level for messages */
    canREG1->INTMUXx[0U] = 0x00000000U
    | 0x00000000U
    | 0x00000000U
    | 0x00000000U
    | 0x00000000U
    | 0x00000000U
    | 0x00000000U
    | 0x00000000U
    | 0x00000000U
    | 0x00000000U
    | 0x00000000U
    | 0x00000000U
    | 0x00000000U
    | 0x00000000U
    | 0x00000000U
    | 0x00000000U;

    canREG1->INTMUXx[1U] = 0x00000000U;

    /** - Setup auto bus on timer period */
    canREG1->ABOTR = 0U;

    /** - Initialize message 1
    * - Wait until IF1 is ready for use
    * - Set message mask
    * - Set message control word
    * - Set message arbitration
    * - Set IF1 control byte
    * - Set IF1 message number
    */
    while ((canREG1->IF1STAT & 0x80U) ==0x80U)
    {
    } /* Wait */


    canREG1->IF1MSK = 0xC0000000U | ((0x3FFFFFFFU & 0x1FFFFFFFU) << 0U);
    canREG1->IF1ARB = 0x80000000U | 0x40000000U | 0x00000000U | ((1U & 0x1FFFFFFFU) << 0U);
    canREG1->IF1MCTL = 0x00001080U | 0x00000400U | 8U;
    canREG1->IF1CMD = 0xF8;
    canREG1->IF1NO = 1;

    /** - Initialize message 2
    * - Wait until IF2 is ready for use
    * - Set message mask
    * - Set message control word
    * - Set message arbitration
    * - Set IF2 control byte
    * - Set IF2 message number
    */
    while ((canREG1->IF2STAT & 0x80U) ==0x80U)
    {
    } /* Wait */

    canREG1->IF2MSK = 0xC0000000U | ((0x3FFFFFFFU & 0x1FFFFFFFU) << 0U);
    canREG1->IF2ARB = 0x80000000U | 0x40000000U | 0x20000000U | ((2U & 0x1FFFFFFFU) << 0U);
    canREG1->IF2MCTL = 0x00001080U | 0x00000000U | 8U;
    canREG1->IF2CMD = 0xF8;
    canREG1->IF2NO = 2;


    /** - Setup IF1 for data transmission
    * - Wait until IF1 is ready for use
    * - Set IF1 control byte
    */
    while ((canREG1->IF1STAT & 0x80U) ==0x80U)
    {
    } /* Wait */
    canREG1->IF1CMD = 0x87;

    /** - Setup IF2 for reading data
    * - Wait until IF1 is ready for use
    * - Set IF1 control byte
    */
    while ((canREG1->IF2STAT & 0x80U) ==0x80U)
    {
    } /* Wait */
    canREG1->IF2CMD = 0x17;

    /** - Setup bit timing
    * - Setup baud rate prescaler extension
    * - Setup TSeg2
    * - Setup TSeg1
    * - Setup sample jump width
    * - Setup baud rate prescaler
    */
    canREG1->BTR = (3U << 16U) |
    ((4U - 1U) << 12U) |
    (((1U + 4U) - 1U) << 8U) |
    ((4U - 1U) << 6U) |
    43U;

    /** - Setup TX pin to functional output */
    canREG1->TIOC = 0x0000004CU;

    /** - Setup RX pin to functional input */
    canREG1->RIOC = 0x00000048U;

    /** - Leave configuration and initialization mode */
    canREG1->CTL &= ~0x00000041U;

    }



    void can_baud_83kbps(void)
    {


    canREG1->CTL = 0x00000000U
    | 0x00000000U
    | 0x00021443U | (1<<2) | (1<<3) ;

    /** - Clear all pending error flags and reset current status */
    canREG1->ES = canREG1->ES;

    /** - Assign interrupt level for messages */
    canREG1->INTMUXx[0U] = 0x00000000U
    | 0x00000000U
    | 0x00000000U
    | 0x00000000U
    | 0x00000000U
    | 0x00000000U
    | 0x00000000U
    | 0x00000000U
    | 0x00000000U
    | 0x00000000U
    | 0x00000000U
    | 0x00000000U
    | 0x00000000U
    | 0x00000000U
    | 0x00000000U
    | 0x00000000U;

    canREG1->INTMUXx[1U] = 0x00000000U;

    /** - Setup auto bus on timer period */
    canREG1->ABOTR = 0U;

    /** - Initialize message 1
    * - Wait until IF1 is ready for use
    * - Set message mask
    * - Set message control word
    * - Set message arbitration
    * - Set IF1 control byte
    * - Set IF1 message number
    */
    while ((canREG1->IF1STAT & 0x80U) ==0x80U)
    {
    } /* Wait */


    canREG1->IF1MSK = 0xC0000000U | ((0x3FFFFFFFU & 0x1FFFFFFFU) << 0U);
    canREG1->IF1ARB = 0x80000000U | 0x40000000U | 0x00000000U | ((1U & 0x1FFFFFFFU) << 0U);
    canREG1->IF1MCTL = 0x00001080U | 0x00000400U | 8U;
    canREG1->IF1CMD = 0xF8;
    canREG1->IF1NO = 1;

    /** - Initialize message 2
    * - Wait until IF2 is ready for use
    * - Set message mask
    * - Set message control word
    * - Set message arbitration
    * - Set IF2 control byte
    * - Set IF2 message number
    */
    while ((canREG1->IF2STAT & 0x80U) ==0x80U)
    {
    } /* Wait */

    canREG1->IF2MSK = 0xC0000000U | ((0x3FFFFFFFU & 0x1FFFFFFFU) << 0U);
    canREG1->IF2ARB = 0x80000000U | 0x40000000U | 0x20000000U | ((2U & 0x1FFFFFFFU) << 0U);
    canREG1->IF2MCTL = 0x00001080U | 0x00000000U | 8U;
    canREG1->IF2CMD = 0xF8;
    canREG1->IF2NO = 2;


    /** - Setup IF1 for data transmission
    * - Wait until IF1 is ready for use
    * - Set IF1 control byte
    */
    while ((canREG1->IF1STAT & 0x80U) ==0x80U)
    {
    } /* Wait */
    canREG1->IF1CMD = 0x87;

    /** - Setup IF2 for reading data
    * - Wait until IF1 is ready for use
    * - Set IF1 control byte
    */
    while ((canREG1->IF2STAT & 0x80U) ==0x80U)
    {
    } /* Wait */
    canREG1->IF2CMD = 0x17;

    /** - Setup bit timing
    * - Setup baud rate prescaler extension
    * - Setup TSeg2
    * - Setup TSeg1
    * - Setup sample jump width
    * - Setup baud rate prescaler
    */
    canREG1->BTR = (1U << 16U) |
    ((6U - 1U) << 12U) |
    (((1U + 6U) - 1U) << 8U) |
    ((4U - 1U) << 6U) |
    4U;

    /** - Setup TX pin to functional output */
    canREG1->TIOC = 0x0000004CU;

    /** - Setup RX pin to functional input */
    canREG1->RIOC = 0x00000048U;

    /** - Leave configuration and initialization mode */
    canREG1->CTL &= ~0x00000041U;

    }