cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 CAN HAL

n.serina
Associate III
Posted on May 09, 2018 at 17:11

Hello, 

For every peripheral like SPI,I2C,USART , etc, ST's HAL gives 3 types of apis like poll, IT and DMA . Why this is not applicable to CAN bus ? I dont find an api like can_transmit_IT or receive_it in the latest stm32f4xx_hal_can.c 

i am referring to 

STM32Cube_FW_F4_V1.21.0\Drivers\STM32F4xx_HAL_Driver\Src

#stm32-disc #stm32f4-nucleo
1 REPLY 1
T J
Lead
Posted on May 10, 2018 at 07:42

I use interrupts for everything, but Can_Tx

this is how to Tx Can, no interrupts needed.

       

 if ((CAN->TSR & CAN_TSR_TME0) == CAN_TSR_TME0)                                                         // (1)

  {

                       

  CAN->sTxMailBox[0].TDTR = canTxMsgLength[canTxMsgOUT];                               // (2) length

  CAN->sTxMailBox[0].TDLR = canTxMsgBottomWord[canTxMsgOUT];                      // (3) 4bytes

  CAN->sTxMailBox[0].TDHR = canTxMsgTopWord[canTxMsgOUT];                          // (3) 4bytes

  CAN->sTxMailBox[0].TIR  = ((uint32_t)canTxMsgID[canTxMsgOUT] << 21 | CAN_TI0R_TXRQ);        // (4)    // send it now if the line is idle

}