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


Trying to figure out why my timer only ticks once

Greetings,

Relatively new to the platform, I’m trying to write a simple ‘blinkenlight’ test on an iM880A LoRa development board, which uses a STM32 chip.

I’m trying to do this using a Timer implementation, but for some reason, the timer only ticks once.

See also the attached cpp file.

I know that send_message is called once, because the led lights up after programming.
Removing ‘GpioWrite(&sensing_flag, flagState);’ on line 110 has the effect that the led does not light up.
Starting the code with ‘int flagState = 1;’ on line 21, causes it to set it to 0 and the led still does not light up. I know the chip is doing something, because adding a simple counter in the main loop that counts to 100000 and updating the state causes the led to actually blink.

Any insights in the situation are cheerfully appreciated. :-)

France

Hi,

How did you create your project? It does not seem to be a CubeMX-generated project neither a System Workbench generated one, or at least you do not use the firmwares provided by ST; you should have includes of the firmware definition files for your microcontroller.

I don’t know what the TimerInit and TimerSetValue do exactly, but I wonder if they do not initialize the timer in one-shot mode... I don’t know either what the TimerLowPowerHandler is doing.

Also, in send_message, I would probably just write
flagState ^= 1;


Bernard (Ac6)


The project is an attempt to create a boilerplate from (probably) known good code. (Colleague of mine left without leaving behind a lot of knowledge)
I was kind of afraid for this already, but it would appear that the libraries I’m using (the ones from imst.com for this devboard) are too product specific for the question to be asked here. Timer- functions are defined in those libraries as well, but I was just hoping that Timer-based things were common enough to be known here.


flagState ^= 1 tip: Thanks. :-)

You need to provide more context. By “timer” are you refering to one of the hardware timers or something like a software timer for a RTC that “ticks” periodically? Speaking from experience, if it’s a hardware timer, it has to have a clock source. If that source is not internal, then maybe your external source is not connected or not working. If it’s something that gets an interrupt each time, then maybe the interrupts were not cleared to reenable them. Same goes for software timers, which are usually triggered by a hardware timer (e.g. to “tick” every X msec): if the hardware timer was not set correctly, then that could be the problem. Or if it’s OK, then the interrupt for the “tick” was not cleared for the next tick event. If’s always better to provide more details, then not enough. It’s like aliasing when sampling analog signals for DSP, if you sample slower than the Nyquist rate, you most likely will not get what you wanted (unless you intentionally undersampled because it then aliases into a clean part of the spectrum), but I am providing too much detail.

 

Newest Forum Posts

  1. SPI on Nucleo_STMH533RE by royjamil, 20:13
  2. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-25 07:37
  3. SPI on Nucleo_STMH533RE by royjamil, 2025-03-23 11:31
  4. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-23 09:33
  5. Configuring DMA for ADC in SW? by sam.hodgson, 2025-03-04 12:58
  6. Build a project in "release" mode by info@creosrl.it, 2025-02-20 18:12
  7. Build a project in "release" mode by info@creosrl.it, 2025-02-20 17:05
  8. Build a project in "release" mode by tang, 2025-02-20 10:36
  9. Build a project in "release" mode by info@creosrl.it, 2025-02-19 17:35
  10. Fail to debug in Win 11 C/C++ by mortenlund, 2024-12-26 20:27

Last-Modified Blogs