How to change can bus speed in run time with PE CAN_LDD component

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

How to change can bus speed in run time with PE CAN_LDD component

1,599 Views
paoloa_
Contributor I

Hi everyone,

I have a TRK-KEA128 board and I'm developing a  can bus project. I am using Code Warrior 10.6 and Processor Expert and I setting the LDD_CAN component with bit rate @100kbits/s and listen only mode.

Is there a way to setting the bit rate in run time? I need to connect the board to various can bus networks that I don't know the bit rate.

Thank you for help,

Paolo

0 Kudos
Reply
4 Replies

1,350 Views
paoloa_
Contributor I

OK, thank you Jennie.

I saw that this question is already in Kinetis Microcontroller forum.

I hope somebody can help me....I'll be waiting for.......

Best regards

Paolo A.

0 Kudos
Reply

1,350 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi Paolo.

I contacted the processor expert developer today.  I got there is not supported list of values in the timing dialog of the CAN_LDD component (see the screenshot below). There is also not any method of the component that provides configuration of the CAN device timing. I am sorry but this functionality is not supported by the CAN_LDD component.

pastedImage_1.png


Have a great day,
Jennie Zhang

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

1,350 Views
paoloa_
Contributor I

Hi Jennie,

    thank you for reply, but.....

If I want to use KEA128 series MCU for my application, how do I change the bit rate? Even without using PE....

I tried to implement the following snippet code:

/* the init speed is 250Kbits/s, if the bit rate is different change the speed after timeout */

while((!DataFrameRxFlg) && (Timeout<TIMEOUT_MS))
  {                                      
      /* Wait until data frame is received or trigger timeout*/
  }
  if(Timeout>TIMEOUT_MS)                                // After timeout change can bus bit rate (5 s)
  {
    //Timeout reset
    Timeout = 0;
   
    // Disable can bus driver
    CAN1_Disable(MyCANPtr);
    /* MSCAN_CANBTR0: SJW=0,BRP=0x21 */
    MSCAN_CANBTR0 = (MSCAN_CANBTR0_SJW(0x00) | MSCAN_CANBTR0_BRP(0x21)); /* Set the timing register 0 */
    /* MSCAN_CANBTR1: SAMP=0,TSEG2=1,TSEG1=3 */
    MSCAN_CANBTR1 = (MSCAN_CANBTR1_TSEG2(0x01) | MSCAN_CANBTR1_TSEG1(0x03)); /* Set the timing register 1 */
    //Enable can bus driver
    CAN1_Enable(MyCANPtr);
  }

/* now the bit rate is about 100Kbits/sec */

but after timeout (5 seconds) it seems occurs a system reset and the speed doesn't change. 

I remember that can bus received data frame with interrupt service.

Thank you

Paolo A.

0 Kudos
Reply

1,350 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi Pacolo.

Thanks for your reply.

However for CAN usage, I suggest you contact Kinetis community space, we have expert monitoring there.

https://community.nxp.com/community/kinetis 

This space is mainly for IDE and  tool usage.

Thanks for your understanding.

Best Regards.

Jennie Zhang

0 Kudos
Reply