Skip to main content
Graduate
December 14, 2023
Solved

STM32G431 bug in fdcan? - no databytes send

  • December 14, 2023
  • 3 replies
  • 1662 views

Hi,

i a trying to figure out, why my fdcan is not sending databytes. It only sends the id.

And i think i found a bug. Or maybe its just me having not enough knowledge to comprehend it.

In the function "FDCAN_CopyMessageToRAM" there is a part, where the data length is bit shifted to zero.

data zero.jpg

    This topic has been closed for replies.
    Best answer by Tobe

    I found the problem and fixed the issue: I was not using "FDCAN_data_length_code" for the data length.

    I added this to the code to make it work using it without "FDCAN_data_length_code":

     

    fixed.jpg

    IF it is NOT the actual "length", it should be named "lengthCode"... :thumbs_down:

    3 replies

    TobeAuthor
    Graduate
    December 15, 2023

    I removed the bit shift, and the bytes are transferred to the txAddress. But still it wont send the bytes. I feel like i am on the complete wrong track? But the bitshifft still makes no sense at all to me.

     

    its there.jpg

    fdcaninit.jpg

    Graduate II
    December 15, 2023

    Show more relevant code. How are you initializing the FDCAN_TxHeaderTypeDef and data?

     

    TobeAuthor
    Graduate
    December 15, 2023

    I added the init code.  But cant you tell, that any uint8_t shifted 8 or more bits to the right is always 0?

    TobeAuthorAnswer
    Graduate
    December 15, 2023

    I found the problem and fixed the issue: I was not using "FDCAN_data_length_code" for the data length.

    I added this to the code to make it work using it without "FDCAN_data_length_code":

     

    fixed.jpg

    IF it is NOT the actual "length", it should be named "lengthCode"... :thumbs_down:

    Graduate II
    December 15, 2023

    FDCAN_CopyMessageToRAM is declared static so you shouldn't have removed static keyword to use that function.

    Instead you need to use HAL_FDCAN_AddMessageToTxFifoQ

    TobeAuthor
    Graduate
    December 15, 2023

    Yes, but HAL is pretty bloated, and i am working on a bootloader.