Skip to main content
Piyush_Gupta
Associate II
January 24, 2023
Solved

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

  • January 24, 2023
  • 9 replies
  • 3944 views

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.
    Best answer by Tesla DeLorean

    Do you initialize the tick5 value at loop entry?

    Is this in a callback?

    Does the tick count advance here?

    9 replies

    Tesla DeLorean
    Tesla DeLoreanBest answer
    Guru
    January 24, 2023

    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
    January 25, 2023

    @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
    January 25, 2023

    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
    January 27, 2023

    >>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
    January 25, 2023

    >>but it works properly without that condition

    show us

    hit me up in https://www.linkedin.com/in/javiermuñoz/
    Piyush_Gupta
    Associate II
    January 27, 2023

    0693W00000Y9IQBQA3.bmp0693W00000Y9IQ6QAN.png

    Piyush_Gupta
    Associate II
    January 27, 2023

    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
    January 27, 2023

    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
    January 28, 2023

    without HAL_Delay() ???