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

PSoC™ 5, 3 & 1 Forum Discussions

luisji
Level 4
50 sign-ins 25 replies posted 25 sign-ins
Level 4

Hello.    Do somebody has an example of an interrupt based clock in C language for PSoC 5?    The intention is not to use the uController on delays that ignores all the rest of the system, but to have all timed subrutines comparing the initial time of them and the present time to know if the time of their task has passed and need to stop.   The clock gets the time dividing enough tics of an internal clock to get maybe uSeconds or what be needed and be possible, then the time variable is readed by each subroutine who need it.  

One way could be to use a Real Time external Clock, but I think it could take too much time to read it. 

Have a nice day

Luis

 

0 Likes
1 Solution
Len_CONSULTRON
Level 9
1000 replies posted 750 replies posted 500 likes received
Level 9

Luis,

Attached is a very simple program that uses the SysTick counter with 1ms resolution that times out 8 events.

It uses the SysTick ISR in count down mode to turn off outputs at the programmed timed interval.

Here's a scope pic of the output results:

PRINT_05.png

Len
"Engineering is an Art. The Art of Compromise."

View solution in original post

0 Likes
2 Replies
Len_CONSULTRON
Level 9
1000 replies posted 750 replies posted 500 likes received
Level 9

Luis,

I have used the SysTick timer resource on many projects.   It is intended for the use you described.  Plus it doesn't take away from other PSoC timer resources.

It is normally configured to generate an interrupt every 1ms.  However, with proper care it can be programmed to interrupt at faster intervals.

When I use the SysTick resource, I commonly use it as a timestamp. When I want a timed operation, I read the SysTick immediate value and add to it the end value of the SysTick when the operation should be completed.   This computed end SysTick value is my completion timestamp for this operation.

I then go an do other things.  I consistently check if the timestamp has expired.  If so, I perform the operations needed.

In a number of my projects, I have used multiple timestamps within the same project.  The only resource cost is the RAM needed for each timestamp.

What is the smallest timing resolution you want to support?  (1ms is the default)

How timing critical is detecting the end of a timing period?  +10 SysTicks?  +1 SysTicks?  < 1 SysTick?

Len
"Engineering is an Art. The Art of Compromise."
0 Likes
Len_CONSULTRON
Level 9
1000 replies posted 750 replies posted 500 likes received
Level 9

Luis,

Attached is a very simple program that uses the SysTick counter with 1ms resolution that times out 8 events.

It uses the SysTick ISR in count down mode to turn off outputs at the programmed timed interval.

Here's a scope pic of the output results:

PRINT_05.png

Len
"Engineering is an Art. The Art of Compromise."
0 Likes