Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
7 years, 5 months ago.
What timer is wait_us(); using on Stm32L053?
Our target is a STM32L053. We started Timer21 for capture mode, on Pin PA_3:CH2. External 5KHz is on the pin. The CCMR2 is read and values are not stable. (We use timer2 and timer22 for PWM out).
No Timer timer; are used in the code, only FastPWM lib. We do use wait_us(50); in two places. Can this bother timer21?
Code below:
/media/uploads/jmaeng/test_code.c
1 Answer
7 years, 5 months ago.
It is defined here in the source code: https://github.com/ARMmbed/mbed-os/blob/master/targets/TARGET_STM/TARGET_STM32L0/TARGET_NUCLEO_L053R8/device/hal_tick.h
So sadly, the timer (which includes wait_us) runs on timer21. You can use the mbed-dev lib and modify it yourself to run on another timer. Or if it is not too critical, just create your own loop with a certain delay. Either just figure out in a few attempts how long your dummy loop needs to be for a certain delay. Or before you start the timer in capture mode, run your loop for a certain amount of cycles, use a Timer to measure how long your loop takes, and using that information calculate in your program how long you need to set your loop for a delay of 50us.
Thanks! Good to know. Any other timers used? How would I know(any hints) to how to know what hardware is used by the mbed-dev lib for a given CPU? (Or is it only "one timer"...?) Fantastic with mbed in general.
How do one get/build the mbed-dev lib fast and easy?
posted by 28 Jun 2017There is no unified way to know, it really depends per target. Many require one timer for wait/Timer/Ticker, some require 2 or even 3. And then you got PWM timer often on top of that, although for example the LPC1768 has a dedicated PWM timer.
Besides experience and checking mbed source code I don't really got an answer for you sadly.
posted by 29 Jun 2017