1333 views|0 replies

73

Posts

0

Resources
The OP
 

[N32L43X Review] 4.Timer&MultiTimer Hardware Timer and Software Timer [Copy link]

 

N32 has rich timer resources

There are two advanced timers (TIM1, TIM8) with PWM complementary output

5 normal timers (TIM2, TIM3, TIM4, TIM5, TIM9)

2 basic timers (TIM6, TIM7)

There is also a low power timer and 2 watchdog timers, and a basic Systick

Systick asked me to use it for Delay application, so I chose a normal timer as the system time base timer.

First of all, we need to understand that the clock bus of TIM belongs to APB1, which is 1/4 of the main frequency by default, that is, when the main frequency is set to 108MHz, the APB bus is 27MHz. In order to use the USB function in the future, the main frequency is set to 96MHz

If you use the advanced timer (TIM1, TIM8), please note that the APB2 clock is 1/2 of the main frequency.

Once the clock frequency is determined, the frequency can be divided according to this configuration.

1/4 of 96MHz is 24MHz, and dividing by 24 times is exactly 1MHz

Then if the load value is set to 1000, it will be 1mS

Such a normal timer function is completed

Usually the hardware timer configuration and calling are a bit complicated. Occasionally, I saw the open source MultiTimer, so I was excited.

After testing, it is indeed very convenient and very easy to transplant.

链接已隐藏,如需查看请登录或者注册

There are now two versions, a development version more suitable for Linux systems, and a Master version more suitable for microcontrollers.

There are two versions of the port here. Use whichever you like.

Let me first talk about how to use development

1. Continuously ++ system timing variables through time base timer interrupt

2. Write a function that returns the system timer

3. Configure the required timers

4. Loop and execute MultiTimerYield();

Of course, the functions of the two versions are the same

In this way, one hardware timer can be used to expand N timers, and the calling method is also very simple, which is very suitable for microcontrollers with limited resources.

In addition, the author also has a button driver MultiButton

链接已隐藏,如需查看请登录或者注册

It is also very easy to use. It can recognize functions such as pressing and releasing, double-clicking and long pressing. If you are interested, I will find time to port it to N32.

4.Timer&MultiTimer_Master.rar

104.73 KB, downloads: 9

4.Timer&MultiTimer_Development.rar

103.9 KB, downloads: 0

This post is from Domestic Chip Exchange
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list