I'm afraid this is going to have to be my first 'vague' post in that I can't yet divulge the exact nature of this project. However, I'm sure I can word the question perfectly well still. Amongst details, specific questions are in bold.
[u]What I want to do, is when a counter running in my program reaches and/or exceeds a certain value, I want the chosen digital pin to go high for a set amount of time, and then go low again. But not as simply as that, please read on.[/u]
Now, I know if the program were as simple as that - one would probably just use a normal digital pin and use a timer like the micro function, however - I've got LOTS going on at the same time, as this is fairly time critical.
I know the PWM function is implemented using the Output Compare function which are located on specific pins, however - I'm not too sure how the PWM function actually works. I believe those pins run their own timer, so when a value is exceeded - the output is flipped. However, this timer is not one 'running in the main program'. So, does it sound like the above requirement could make best use of an Output Compare capable pin?
I suppose actually, what I am trying to ask - and have just realised it writing the above, is when that condition becomes true at which point I want an output to go high, I want this to generate some sort of "software interrupt" - in that the MCU pauses what it is currently doing and runs an ISR to switch the output on and then returns to the main program, where it can be turned off when another timer is exceeded. Are such "software interrupts" possible?
Or, using an Output Compare method as described above, the ISR that is run sets the pin high THEN sends the time for which the pin should remain high to the Output Compare pin. That way, the ISR sets the pin high - control is returned to main, then the Output Compare timer pulls the pin low after the time 'sent' by the ISR is reached.
I hope the above made sense!
EDIT: The reason I'm asking this here, and not in the programming section - is I'm decided which physical pin to use, which obviously determines board layout - thus being a hardware question.