18F4520 4Mhz Internal Osc, 300 Baud TX only, watchdog used.
I have an application that need to look for a button low press on A5 about every 100ms. As this port/pin cannot use ext interrupts like port B, I have to find another method. I had thought about using a timer to run a check periodically, but am not sure which one to use as I do not want to interfere with watchdog or serial out, not sure how to impliment it either. I had thought of using CCS built in RTOS, but as the called function runs for about 5 seconds I understand that schedule time would have to be longer than the function time, this of course means that scanning for a button press ever 5+ seconds would be next to useless. Not used this RTOS before, so what I was thinking was that if I ran the task every 100ms and called the function, checked for bounce and if invalid, return. If it was a valid press, could I then stop the task from within the function and resume it when finished, thus leaving the main program running without task switching, or could it only be stopped from main.
It would be impractical to use polling in this application, even though it would not be a major issue if the main function paused for the duration of the called function. Any advice or alternative suggestions would be most welcome.
Added after 3 hours 27 minutes:
I think I may have misunderstood the CCS implementation. Assuming I have a function that is little more than a delay, and that I use an Rtos like Keil, I would expect to be able to switch to it, say every 20ms and it would carry on its timing where it left off last time until completion. Obviously there would be some variation in timing due to switching. As I understand it in CCS, you do not get control back until the function is complete. This seems no more useful than using an interrupt. Surely I must have this wrong, the explanations are really not clear at all. Can anyone confirm or deny?