Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

ASYNC software timers on separate hardware timers

Status
Not open for further replies.

jasaleja

New Member
Hello everyone,

I wrote a little code for my MSP432 to use two software timers on two separate hardware timers.

The first hardware timer runs on SMCLK 3Mhz/64 and counts to 46875 before the interrupt. That is 1 second. And on that timer runs a software timer that counts 2 seconds, and then it triggers a red LED.

The second hardware timer runs on SMCLK 3Mhz and counts to 3000 before the interrupt. That is 1 m second. And on that timer runs a software timer that counts 500 m seconds, and then it triggers a blue LED.

So after i run the program the blue and red LED should both turn off after 4 seconds. But after a few minutes the 2 LEDS get async and i dont know why.

Does someone have an explanation?

I think it's because no 2 hardware timers can be in sync.
 

Attachments

  • main.c
    4.7 KB · Views: 444
I think it's because no 2 hardware timers can be in sync.
Both hardware timers are running from the same 3mhz clock. They should stay lock together.

I can not see your code here. (my computer)
I have seen code where a divide by 3000 is actually 3001 or 2999 (one count off) because I did not understand numbers. LOL
But after a few minutes the 2 LEDS get async
After more time do the two LEDs get back together? I am trying to determine if they are off by 1/3000 or 1/46875.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top