Correct TickHook application

kkelkar wrote on Wednesday, July 18, 2007:

I want to access the DBGU UART on a SAM7S256 using an ISR. My understanding is that DBGU interrupts show up as a SYS interrupt, which is the interrupt used by the tick timer. Therefore, I believe that I need to place my ISR into TickHook. My questions are:
1. Can anyone confirm that this is the right way to do so? If not, can you please let me know a better way to accomplish what I want to do?
2. If this is the right way, is TickHook necessarily a coroutine?
3. Do I need to enable coroutines to put in a tickhook, or merely just enable tickhook?
3. Can I use a xQueueReceiveFromISR from within tickhook, or do I need to use crQUEUE_RECEIVE_FROM_ISR?
4. If tickhook is a coroutine, does it need to yield or just return?

I also wish to put the system in idle mode when it is not doing anything. My understanding is that I can do so by creating an idlehook routine. My questions related to this are:
1. Is idlehook necessariloy a coroutine?
2. Do I need to enable coroutines to put in an idlehook or merely just enable idlehook?
3. If I put the processor into idle mode in idlehook, will it automatically come out of idle mode when a task is ready or do I need to take it out of idlemode in a tickhook routine?
4. Does idlehook need to yield or just return?

Any help would be very much appreciated.

Thanks in advance.

davedoors wrote on Wednesday, July 18, 2007:

One way to use two system interrupts is to have a single system interrupt handler ISR.  The ISR looks at the status bits of the system peripherals and calls a standard function to handle either the PIT or the DBU handler as appropriate.  You need to take care that the context is saved before this is done.  You do not use the tick hook.

The idle hook has nothing to do with coroutines other than it being a convenient place to call the coroutine schedule function.  All you need to do is enable the idle hook then write a function:

void vApplicationIdleHook( void )
//place processor into sleep mode here

The sleep mode chosen must ensure that timer interrupts will wake the processor up again.

kkelkar wrote on Thursday, July 19, 2007:

Thanks Dave. That was very helpful.