I have a a series a flags in my code that signify either stages of Serial reception or errors.
For Example:
Rx_Data meaning the new Byte of data has been received
CRC_Error meaning CRC error
FEC_Error Forward Error Correction not possible
The flags are arranges so that only the most significant error is prioritised.
What I would like to do is show the error on a single LED and use either the number of pulses the led is On or the duty cycle to indicate the error.
For example
when the RX_Data flag is set the led will toggle on off at the same time period (say 500ms)
When the CRC_Error Flag is set the Led will pulse for twice and then stay off for for one period.
I have represented the LED Status in the attached graphic.
When the flag is cleared the Status will then report the next lower priority. If no data received, the LED will be fully ON.
What I am trying to get my head around is to how to implement such function. I figured I would use timer0 on the Mega16 to set the pulse period, and I can toggle the LED when the RX_Data flag is set. But, it is the others I am having difficult working out.
Can you suggest an approach I can investigate?