Skip to main content
Piyush_Gupta
Associate II
Jan 24, 2023 12:15 PM UTC
Solved

CAN Bus Protocol Transmitter doesn't work inside time-delay condition....

When I try to transmit can CAN data it doesn't work inside the time-delay condition... but it works properly without that condition...

Does anyone knows what's the issue?

Regards0693W00000Y91N5QAJ.png

    This topic has been closed for replies.
    Tesla DeLorean
    Tesla DeLoreanBest answer
    Guru
    Jan 24, 2023 2:30 PM UTC

    Do you initialize the tick5 value at loop entry?

    Is this in a callback?

    Does the tick count advance here?

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..

    9 replies

    Tesla DeLorean
    Tesla DeLoreanBest answer
    Guru
    Jan 24, 2023 2:30 PM UTC

    Do you initialize the tick5 value at loop entry?

    Is this in a callback?

    Does the tick count advance here?

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    Piyush_Gupta
    Associate II
    Jan 25, 2023 2:51 AM UTC

    @Community member​ 

    >>Do you initialize the tick5 value at loop entry?

    I have initialized it as a global variable

    >>Is this in a callback?

    No, its in the main while loop

    >>Does the tick count advance here?

    I'm new to stm32, don't know what your question is....

    I just want to send data using CAN BUS at every 200-300ms. But when I try to transmit it in if(HAL_Getick() - tick5 > 200) it doesn't work....

    Tesla DeLorean
    Guru
    Jan 25, 2023 2:36 PM UTC

    Is HAL_GetTick() incrementing as each millisecond passes within the loop?

    If you send a character to a UART as well, can you see that occur periodically?

    Does HAL_CAN_AddTxMessage() return success or failure codes? Should you need to use more than one mailbox?

    I understand the goal, just not sure if it's not attempting to send at all, or if the approach here is wrong, or has unexpected modes of failure that you're not addressing or handling.

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    Piyush_Gupta
    Associate II
    Jan 27, 2023 5:18 AM UTC

    >>Is HAL_GetTick() incrementing as each millisecond passes within the loop?

    yes, its incrementing

    >>If you send a character to a UART as well, can you see that occur periodically?

    I can't do this, it's a customize development board with no USB-UART TTL and no other free gpio pins, I will check the schematic again

    >>Does HAL_CAN_AddTxMessage() return success or failure codes?

    it return success code, but when I checked on oscilloscope, there is no signal...

    Javier1
    Principal
    Jan 25, 2023 2:40 PM UTC

    >>but it works properly without that condition

    show us

    hit me up in https://www.linkedin.com/in/javiermuñoz/
    Piyush_Gupta
    Associate II
    Jan 27, 2023 5:21 AM UTC

    0693W00000Y9IQBQA3.bmp0693W00000Y9IQ6QAN.png

    Piyush_Gupta
    Associate II
    Jan 27, 2023 7:46 AM UTC

    Could you let me know, how to transmit data using CAN Protocol after a time period. I just want to transmit data after a time period...

    KnarfB
    Super User
    Jan 27, 2023 8:57 AM UTC

    You can wait a time period, say 200ms, simply with HAL_Delay(200) in the while loop after sending each message.

    hth

    KnarfB

    Piyush_Gupta
    Associate II
    Jan 28, 2023 4:31 AM UTC

    without HAL_Delay() ???