- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Solved! Go to Solution.
- Labels:
-
PSOC5 LP MCU
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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:
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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:
"Engineering is an Art. The Art of Compromise."