- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi there,
I need an PWM signal so that I can trigger specific action depending on the level of the PWM. So I set up the PWM with interrupts enabled for terminal count event and compare 1 event. I expected to get an interrupt when the compare value matches the counter and at the end when the counter reaches zero. But I get two interrupts simultaneously, or only microseconds apart.
I clock the PWM with 10 kHz and set the period to 12000 and the compare value to 9000. The compare type is greater. I get a PWM signal with 300ms high value and a period of 1200ms as expected. But not compare 1 interrupt after 300ms as expected.
What do I miss here?
Solved! Go to Solution.
- Labels:
-
PSOC5 LP MCU
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
user,
Simple. The issue is that the PWM is a count-down counters. Therefore the count starts with period value and counts down. A "Greater than" occurs once the period value is reloaded into the counter after the terminal count.
The simple fix is to use "Lesser than" and use a NOT gate on the PWM output.
I've attached an example project with these changes.
Here's a scope pic of the outputs:
"Engineering is an Art. The Art of Compromise."