Loading...
 

Zephyr project on STM32

   Zephyr Workbench, a VSCode extension to manage Zephyr on STM32.
It enables users to easily create, develop, and debug Zephyr applications.
Main features:
  • Install host dependencies.
  • Import toolchain and SDK.
  • Create, configure, build and manage apps.
  • Debug STM32.
You can directly download it from the VSCode marketplace
For more details, visit the Zephyr Workbench

System Workbench for STM32


CAN Filter Setup for F091

I’m using HAL functions for STM32F091CC.
When CAN Filter is disabled, all the messages are received,
When CAN Filter is setup and enabled, only the global addressed message is received.

It works fine for STMF103CB.

Here is the function to setup the CAN filter for F091CC.

HAL_StatusTypeDef MX_CAN_Config(void)
{
CAN_FilterConfTypeDef sFilterConfig;

/* Configure the CAN Filter 0 for FIFO 0 with node id=0x02 */
sFilterConfig.FilterNumber = 0;
sFilterConfig.FilterMode = CAN_FILTERMODE_IDMASK;
sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT;
sFilterConfig.FilterIdHigh = (uint32_t)0x02 & 0x3F80;
sFilterConfig.FilterIdLow = 0;
sFilterConfig.FilterMaskIdHigh = 0x3F80;
sFilterConfig.FilterMaskIdLow = 0;
sFilterConfig.FilterFIFOAssignment = CAN_FIFO0;
sFilterConfig.FilterActivation = ENABLE;
sFilterConfig.BankNumber = 1;

if(HAL_CAN_ConfigFilter(&hcan, &sFilterConfig) != HAL_OK)
{
return HAL_ERROR;
}
/* Configure the CAN Filter 1 FIFO 0 for global id */
sFilterConfig.FilterNumber = 1;
sFilterConfig.FilterIdHigh = 0;
sFilterConfig.FilterFIFOAssignment = CAN_FIFO0;

if(HAL_CAN_ConfigFilter(&hcan, &sFilterConfig) != HAL_OK)
{
return HAL_ERROR;
}

// set buffer pointers
hcan.pTxMsg = &TxMessage;
hcan.pRxMsg = &RxMessage;
/* Configure Transmission process */
hcan.pTxMsg->RTR = CAN_RTR_DATA;
hcan.pTxMsg->IDE = CAN_ID_EXT;
hcan.pTxMsg->DLC = 0;
// enable can rx with interruptions
HAL_CAN_Receive_IT(&hcan, CAN_FIFO0);
HAL_CAN_Receive_IT(&hcan, CAN_FIFO1);

return HAL_OK;
}

 

Newest Forum Posts

  1. Монтаж камина с грилем в Москве - установка и барбекю by KpddomErorb, 2025-05-10 18:28
  2. SPI on Nucleo_STMH533RE by royjamil, 2025-05-04 20:13
  3. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-25 07:37
  4. SPI on Nucleo_STMH533RE by royjamil, 2025-03-23 11:31
  5. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-23 09:33
  6. Configuring DMA for ADC in SW? by sam.hodgson, 2025-03-04 12:58
  7. Build a project in "release" mode by info@creosrl.it, 2025-02-20 18:12
  8. Build a project in "release" mode by info@creosrl.it, 2025-02-20 17:05
  9. Build a project in "release" mode by tang, 2025-02-20 10:36
  10. Build a project in "release" mode by info@creosrl.it, 2025-02-19 17:35

Last-Modified Blogs