cancel
Showing results for 
Search instead for 
Did you mean: 

What is the name of the Timer 6 count register? TIM6_CNT is what the documentation says but that is an unknown variable to the compiler.

KiptonM
Lead

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:

  • Counter Register (TIMx_CNT)
  • Prescaler Register (TIMx_PSC)
  • Auto-Reload Register (TIMx_ARR)

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.

1 ACCEPTED SOLUTION

Accepted Solutions
5 REPLIES 5

TIM6->CNT

JW

KiptonM
Lead

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.

It's easier simply accept the fact, that registers marked as ***_YYY are accessed as ***->YYY.

JW

KiptonM
Lead

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

> 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