cancel
Showing results for 
Search instead for 
Did you mean: 

How to update BLE characteristics via timer interrupt in STM32WB55 ?

AndreasC
Associate II

Hello everyone,

I'm trying to use the timer interrupt callback to modify the GATT characteristics and send out a notification (see code excerpt below). This only works once and after sending the message the timer no longer triggers and I no longer see any advertisements from my board. If I send the data via the USB-COM port, it works using the timer interrupt. So there seems to be something wrong with the IPCC but I don't know what it is and how I can fix it/get around it.  can someone help me ?

 

Many Greetings,

Andreas 

 

 

 

 

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_RTC_Init();
  MX_USB_Device_Init();
  MX_TIM16_Init();
  MX_RF_Init();
  /* USER CODE BEGIN 2 */

static uint8_t cnt = 0;
const  uint8_t  max_cnt = 255;
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
	// Check which version of the timer triggered this callback
	if (htim == &htim16 )
	{
		if (cnt % (max_cnt - 1) == 0) cnt = 0;

		uint8_t data[1];
		memcpy(data, &cnt, sizeof(cnt));
		cnt++;
                
                // only one of the two is active at a time!

                // This part for BLE, works just once!
		// Custom_STM_App_Update_Char(CUSTOM_STM_TEMPERATUR, data);
                
                // This USB-part works allways as desired
		uint16_t data_len = (uint16_t) sizeof(data)/sizeof(uint8_t);
		CDC_Transmit_FS((uint8_t*)data, data_len);
	}
}

 

 

 

 

 

1 REPLY 1
STTwo-32
ST Employee

Hello @AndreasC 

In fact, you have to add a task that do this on the Sequencer that run all code tasks. So, whenever the sequencer starts, the execution will be only for tasks included on this Sequencer. For the timer, you can use a HW_Timer. More details that can be helpful are available on the AN5289 specially the part 4.5.

Best Regards.

STTwo-32

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.