cancel
Showing results for 
Search instead for 
Did you mean: 

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

Piyush_Gupta
Associate II

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

1 ACCEPTED SOLUTION

Accepted Solutions

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
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

9 REPLIES 9

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
Up vote any posts that you find helpful, it shows what's working..
Piyush_Gupta
Associate II

@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....

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
Up vote any posts that you find helpful, it shows what's working..
Javier1
Principal

>>but it works properly without that condition

show us

>>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...

0693W00000Y9IQBQA3.bmp0693W00000Y9IQ6QAN.png

Piyush_Gupta
Associate II

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
Principal III

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

hth

KnarfB

without HAL_Delay() ???