- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This may have been solved before but I was unable to find the info. Here's my solution:
In trying to create a "soft switch" I connected a SPST pushbutton to a digital input pin and triggered a one shot timer with an interrupt on terminal count. The timer was set for four seconds which means the PB had to be held for four seconds before the switch would be recognized and turn on and LED (used for testing). However, I also wanted to turn it off by holding the same PB for another 4 seconds (after the PB had been released). Turning it on worked fine but it wouldn't turn off. The problem is that the one-shot timer is REALLY one shot, meaning it will only work once after the program has been started. It couldn't be reset from any API. The only way to get it to work again was to restart the program.
The solution was as simple as it could possibly be, though it took me a long time to figure it out. I simply changed the timer's run mode to Continuous instead of One-Shot, then stopped the timer in the ISR. The APIs work when the Continuous Mode is selected.
Solved! Go to Solution.
- Labels:
-
BLE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The timer needs a reset which you could provide using a control register component.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The timer needs a reset which you could provide using a control register component.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I thought that the timer can be reset by calling _Stop()/_Start() again, or by its reset signal (for the UDB based timer). You might to write a 0 to the counter register before, though.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
decoburn,
take a look into Cypress "soft" switch example project and application note (AN54460 - PSoC® 3 and PSoC 5LP Interrupts):
The project of interest there is B_PICU, showing "software button" setup without sparing hardware resources (e.g. Timer). Quite enough for simple SPST button interface.