Problem to generate 1ms Interrupt on 4200L

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi,

   

I need an 1ms Timer Interrupt, but I already use 8 TCPWM and 4 UDB for PWM ,so no more availible.

   

I only need a ISR every 1ms.

   

 

   

Regards,

   

Michael

0 Likes
13 Replies
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

Please post your code so we can check it.

0 Likes
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted
        I see two options. 1. Set clock to 1khz and connect it to an interrupt thru a pin, or set clock to 2 kHz and connect it to interrupt thru TFF (if macrocels still available). 2. Use SysTick timer to generate 1ms interrupt http://www.cypress.com/comment/238486 http://www.cypress.com/forum/psoc-4-architecture/using-systick-timer-counter   
0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

... and one more suggestion: use the WDT (under low frequency clocks)

   

 

   

Bob

0 Likes
Anonymous
Not applicable

WDT ist the best solution for me, but not easy to find...

   

Thanks Bob you are the greatest!

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Not too much!

   

Where in Germany are you located? I live near Bremen.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

I live near Osnabrück...

0 Likes
Anonymous
Not applicable

I've found that if you have a little spare CPU time, you can implement several timers using the same hardware timer, and thus get more timers for the same hardware, but of course this adds more CPU usage, and multiplexes the timer between the software timers.

0 Likes
        Can you post a demo?   
0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

As Bob mentioned, turning it into a component would involve malloc(), but since I'd rather not debug memory leaks, I've been working with the chip using compile-time operations. Here's a simple example showing the timer multiplexing; I don't have memory allocation like malloc in it, but I do have it scalable to the debug MAX_NUMBER_TIMERS, and it tells you if there is no more room for timers available.

0 Likes

Thank you for demo. Very interesting solution utilizing single timer and isr at fixed rate.

   

For fast hardware timing (us scale), the Timer period can be updated to have only single isr call per "virtual timer". Below is an example of hardware-timed servo controls using single PWM module. The timing will become "hardware timed" as actual period update happens only on counter expiration.  

   

http://www.cypress.com/comment/388031#comment-388031

0 Likes
Anonymous
Not applicable

That's cool! Nice job on the hardware servo control 🙂

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Easiest is to use a callback function which is executed when the internal clock (you need to program one) equals a given value. Making that as universal as a component will require using malloc() and some linked list... Got some time ? ;-))

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Fortunately, when working with small numbers of timers, we can afford to skip linked lists in favor of a for loop 🙂

0 Likes