2021-04-26 07:42 AM
I need a blocking very short time delay.
So I set up Timer 6 to run at 90 MHz, with no interrupts.
I need delays from 0.5 to 30 microseconds for an interface I have to bit-bang.
I was hoping for a simple delay routine like this:
void Timer6_delay(uint16_t clocks)
{
TIM6_CNT = 0;
while (TIM6_CNT < clocks);
}
Except TIM6_CNT is not the right name.
In the documentation: RM0390 it says in Paragraph 19.3.1 Time-base unit it says
The main block of the programmable timer is a 16-bit upcounter with its related auto-reload
register. The counter clock can be divided by a prescaler.
The counter, the auto-reload register and the prescaler register can be written or read by
software. This is true even when the counter is running.
The time-base unit includes:
So I mistakenly thought it was called TIM6_CNT. And if it is, the Compiler does not know about it.
Is it in a special include file I may be missing?
Thanks.
Solved! Go to Solution.
2021-04-26 07:50 AM
2021-04-26 07:50 AM
TIM6->CNT
JW
2021-04-26 08:28 AM
Thank you I also just found it in stm32f446xx.h
I am used to how other microcontrollers name their registers in software with the same name as in the hardware Documentation.
It is not hard to add to the include files:
#define TIM6_CNT TIM6->CNT
So they match the documentation.
Thanks again.
2021-04-26 11:25 AM
It's easier simply accept the fact, that registers marked as ***_YYY are accessed as ***->YYY.
JW
2021-04-26 12:45 PM
Yes of course you are right. This was my first time needing to write to a register. So It was a bit of a surprise.
I can see the advantage if you use pointers to your devices. You can use the exact same subroutine to set up devices the same. Just pass a different pointer in.
Thanks
2021-04-26 12:51 PM
> So It was a bit of a surprise.
It certainly is.
The manuals, datasheets etc. traditionally don't discuss software. Here, an application note would be justified, explaining the basic ways to use the CMSIS-mandated device headers.
JW