infineon4engi@twitter infineon@linkedin infineon4engineers infineon@youtube
twitter Facebook Linkedin Youtube

+ Reply to Thread
Results 1 to 2 of 2

Thread: XMC4200 switch CAN baudrate at runtime

  1. #1
    Beginner Beginner SashaBelykh is on a distinguished road
    Join Date
    Apr 2016
    Posts
    13
    Points
    72.5

    XMC4200 switch CAN baudrate at runtime

    Hello, everyone.

    I have a question about XMC4200 CAN bit timing.
    Could you please guide me, how can I switch it at runtime?
    Specially, if my hardware is already initialized by DAVE's init functions.
    Namely, I need to reinit my CANs from 83333 to 500000.
    Here is my code, which does not work:
    Code:
    void CANxUpdateBaudrate( const CAN_NODE_t* handle, uint32_t baudrate )
    {
      //Disable CAN node participation in CAN traffic
      XMC_CAN_NODE_SetInitBit(handle->node_ptr);
      //Function to configure the baud rate based on UI configuration
      //Keep sample_point and sjw as they was before, update baudrate.
      CAN_NODE_ConfigBaudrate(handle, baudrate, handle->baudrate_config->sample_point, handle->baudrate_config->sjw);
      //Enable CAN node participation in CAN traffic
      XMC_CAN_NODE_ResetInitBit(handle->node_ptr);
    }
    This is usage example:
    Code:
    CANxUpdateBaudrate( &CAN1, 500000 );
    NOTE: my CANs works fine at 83333, I have to update
    Code:
      CAN1_BitTimeConfig.baudrate = 83333;
      CAN2_BitTimeConfig.baudrate = 83333;
    in main.c before DAVE_Init(), because GUI does not allow to set CAN's baudrate less than 100k.
    It also works fine at 500000 baud, if inited by DAVE_Init().

    Now the method, which I use to check how it works:
    I add 2 MOs on my CANs: CAN1, CAN2, one for receive and transmit respectively.
    Then I add Rx and Tx events on needed MOs and link them to corresponding INTERRUPTs.
    When I do so, and enable these INTERRUPTs, they start to occur and receive CAN frames as I expect.
    I'm sending packets every 10 ms and all of them are received.


    This works fine with settings inited by GUI both at 83333 and 500000 bauds.
    But do not work when I try to switch baudrate. At least INTERRUPTs do not occurs.

    For example, I'm starting to send infinit number of frames at 500000 baud/s, and while CAN initialized at 83333 it obviously does not receive anything. But when CAN switches to 500000 it still does not receive anything.

  2. #2
    New Member New Member brian.wisniewski is on a distinguished road
    Join Date
    Jan 2020
    Posts
    1
    Points
    20
    Hi SashaBelykh, I am trying todo something similar, and like you, I am experiencing an issue with the CAN_NODE_ConfigBaudrate(..) API.
    Have you come across a solution?

+ Reply to Thread

Tags for this Thread

Disclaimer

All content and materials on this site are provided “as is“. Infineon makes no warranties or representations with regard to this content and these materials of any kind, whether express or implied, including without limitation, warranties or representations of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. No license, whether express or implied, is granted by Infineon. Use of the information on this site may require a license from a third party, or a license from Infineon.


Infineon accepts no liability for the content and materials on this site being accurate, complete or up- to-date or for the contents of external links. Infineon distances itself expressly from the contents of the linked pages, over the structure of which Infineon has no control.


Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Usage Terms of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Usage Terms of this site. Infineon reserves the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.