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


Generate Software Interrupt (SI) with STM32F· Discovery board with HAL drivers

Thanks for the answer diabolo, and sorry for not answering you earlier. I’ve read more information about FreeRTOS but I still couldn’t figure out how to make a timer properly. Now I’ve defined a timer of 1KHz frequency with the FreeRTOS API and a callback function like this:

/* Create the timer(s) */
/* definition and creation of myTimer01 */
osTimerDef(myTimer01, Callback01);
myTimer01Handle = osTimerCreate(osTimer(myTimer01), osTimerPeriodic, NULL);

/* USER CODE BEGIN RTOS_TIMERS */
/* start timers, add new ones, ... */
osTimerStart(myTimer01Handle,1);
/* USER CODE END RTOS_TIMERS */

/* Create the thread(s) */
/* definition and creation of defaultTask */
osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, 128);
defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL);

In the callback I set a clock of 1KHz in a GPIO and every 100 ms I activate a SWI.

/* Callback01 function */
void Callback01(void const * argument)
{
/* USER CODE BEGIN Callback01 */
HAL_GPIO_TogglePin(GPIOC,GPIO_PIN_1);
contador_timer++;
if (contador_timer == 100){
contador_timer = 0;
flag_SI = 1;
HAL_GPIO_TogglePin(GPIOE,GPIO_PIN_10);
//EXTI->SWIER |= EXTI_SWIER_SWIER0;
__HAL_GPIO_EXTI_GENERATE_SWIT(EXTI_SWIER_SWIER2);
}
/* USER CODE END Callback01 */
}

In the SWI I trie to set a GPIO and wait 200 ms until the next change of value, but the output change every 100 ms and I don’t know why.

void EXTI2_TSC_IRQHandler(void)
{
/* USER CODE BEGIN EXTI2_TSC_IRQn 0 */
if ((__HAL_GPIO_EXTI_GET_IT(EXTI_SWIER_SWIER2) != RESET) && (flag_SI == 1)){
//HAL_GPIO_WritePin(GPIOC,GPIO_PIN_2, GPIO_PIN_SET);
HAL_GPIO_TogglePin(GPIOC,GPIO_PIN_2);
while(delay_SI > 0)
{
delay_SI = delay_SI - 1;
}
delay_SI = 200;
__HAL_GPIO_EXTI_CLEAR_IT(EXTI_SWIER_SWIER2);
flag_SI = 0;

}
/* USER CODE END EXTI2_TSC_IRQn 0 */
HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_2);
/* USER CODE BEGIN EXTI2_TSC_IRQn 1 */

/* USER CODE END EXTI2_TSC_IRQn 1 */
}


There is some manual for the correct configuration of FreeRTOS for STM32CubeMX?

Thanks.

France

Hi,

I don’t understand the use of your waiting loop in EXTI2_TSC_IRQHandler: you will just wait for a few microseconds, or even less, before setting delay_SI to 200. Where did you see a 200ms delay?

According to your code, you toggle GPIO1 every millisecond, and GPIO10 and GPIO2 every 100ms (the first two in the callback, the last in the software generated interrupt handler, which is triggered every 100ms). If you want GPIO2 to be toggled every 200ms you should have a static counter in the SW handler, and only toggle GPIO2 when it is equal to 2 (then reset it to 0).

Bernard (Ac6)


 

Newest Forum Posts

  1. reservation car service Seattle by Jamesprede, 2025-05-01 10:06
  2. Last day: drone bonus by Danielrug, 2025-04-19 16:55
  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. Insightful Perspectives on This Subject by davidsycle, 2025-03-04 05:45
  8. Build a project in "release" mode by info@creosrl.it, 2025-02-20 18:12
  9. Build a project in "release" mode by info@creosrl.it, 2025-02-20 17:05
  10. Build a project in "release" mode by tang, 2025-02-20 10:36

Last-Modified Blogs