TMS570LC4357: Running with Different Hertz

Part Number: TMS570LC4357
Other Parts Discussed in Thread: HALCOGEN

Hi,

In the developed system, i want to running with different hertz value. For examples, first case has to transmit data 50 hertz with canbus and second case has to transmit 100 hertz with canbus line or third case has to receive 50 hertz with canbus line. How can i do this cases ?

  • Hi Dobby,

    I never came across this kind of requirement before on this device. So, we didn't have any direct examples for this thread.

    So, what i did is that i gave your requirement to our internal TI AI tool, this tool specifically designed to analyze all our old e2e threads related to this controller and all the documents related to this controller. After feeding your requirement to this tool i got some suggestions. Please refer this, it might be helpful.

    1. Configure the RTI Timer for Periodic Interrupts

    The RTI module can generate periodic interrupts at various rates. You'll need to:

    • Configure the RTI counter to generate interrupts at your base frequency (e.g., 100 Hz for the fastest rate)
    • Use the RTI compare registers to set up the periodic interrupt timing
    • The RTI module is OSEK-compliant and designed for real-time operating systems(0)

    2. Implement a Task Scheduler in the RTI ISR

    In your RTI interrupt service routine, implement a simple task scheduler:

    volatile uint32_t tick_counter = 0;
    
    void rtiNotification(uint32 notification)
    {
        tick_counter++;
        
        // Case 1: Transmit at 100 Hz (every tick if RTI is at 100 Hz)
        if (tick_counter % 1 == 0) {
            TransmitCANMessage_100Hz();
        }
        
        // Case 2: Transmit at 50 Hz (every 2 ticks if RTI is at 100 Hz)
        if (tick_counter % 2 == 0) {
            TransmitCANMessage_50Hz();
        }
        
        // Case 3: Receive handling can be done in CAN ISR
        // or polled here if needed
    }

    3. Configure CAN Message Objects

    For each transmission case:

    • Case 1 (50 Hz Transmit): Configure a CAN message object for transmission, trigger it from the 50 Hz task
    • Case 2 (100 Hz Transmit): Configure another CAN message object for transmission, trigger it from the 100 Hz task
    • Case 3 (50 Hz Receive): Configure a CAN message object for reception with appropriate message ID filtering

    4. RTI Timer Configuration Example

    The RTI module provides multiple compare interrupts (typically 4 compare channels)(0). You can configure different compare values for different rates:

    // Example: Configure RTI for 100 Hz base rate
    // Assuming RTICLK = 80 MHz and you want 100 Hz
    // Period = 80,000,000 / 100 = 800,000 cycles
    
    rtiInit();
    rtiEnableNotification(rtiNOTIFICATION_COMPARE0);
    rtiStartCounter(rtiCOUNTER_BLOCK0);

    Alternative Approach: CPU Timer

    If you prefer, you can also use a CPU Timer for periodic scheduling. The search results show examples using Timer 0 for periodic CAN message transmission:

    // Configure CPU Timer for periodic interrupt
    // Timer interrupt will trigger CAN transmission

    Key Considerations:

    1. CAN Bit Rate vs. Message Rate: Note that the "hertz" you're referring to is the message transmission rate (how often you send messages), NOT the CAN bus bit rate (e.g., 500 kbps, 1 Mbps). The CAN bit rate is configured separately in the DCAN module.

    2. Message Priority: The DCAN module transmits messages based on priority (numerically lowest message object first). Plan your message IDs accordingly.

    3. Timing Accuracy: The RTI module provides accurate timing for RTOS applications and is ideal for periodic CAN transmission scheduling.

    4. Reception: For receiving messages at specific rates, you can either:

      • Use CAN interrupts (recommended for event-driven reception)
      • Poll the receive message objects in your periodic task

    Example Implementation Flow:

    1. Initialize DCAN module (configure bit rate, message objects)
    2. Initialize RTI module (configure for 100 Hz or your base rate)
    3. In RTI ISR:
       - Increment tick counter
       - Check if it's time to transmit each message
       - Trigger CAN transmission by setting TxRqst bit
    4. For reception:
       - Configure CAN receive interrupt
       - Handle received messages in CAN ISR

    Resources:

    • Refer to the TMS570LC4357 Technical Reference Manual, Chapter 16 for RTI module details
    • Check HALCoGen for code generation examples for RTI and DCAN configuration
    • The RTI module supports multiple periodic alarms that can be configured for different rates

    --
    Thanks & regards,
    Jagadish.

  • Thanks Jagadish for reply. 

    I will try the suggestions.