SAM7X debug unit TX/RX

m_a_d_i_s wrote on Tuesday, April 01, 2008:


In the SAM7X controller there is one UART available under debug unit. But it shares the same interrupt as periodic timer which is used for FreeRTOS scheduler.

In case I would like to use interrupt driven communication via that debug unit (utilise it as normal uart in my project), I have to modify portISR.c to check if its communication interrupt or scheduler tick.

Has anybody done it? Maybe it would be good idea to add some kind of #define to the FreeRTOSConfig.h for SAM7X to specify whether to use debug unit uart or not? Any other ideas?

BR, Madis

saiberion wrote on Tuesday, April 01, 2008:

You’re on the right path. In portISR you have to check from which peripheral the interrupt is coming and handle it.

Here is how I do it:

else if ((((AT91PS_USART)AT91C_BASE_DBGU)->US_CSR & AT91C_US_RXRDY) > 0)

vUsartDebugISR() is an inline function (like vTaskIncrementTick()) that does only puts received data on a queue.
I don’t know if it’s still the case but when I tried it the first time with a normal function call it didn’t work.

I’m not sure where I found this handling. Either in some previous version of FreeRTOS or somewhere here in the forum.

But it is also possible to change the tick timer from PIT to one of the TCs and handle the system interrupt as every other interrupt but I haven’t tried that yet.

pdeflandre wrote on Wednesday, April 02, 2008:

Hello madis and saiberion

I use too the DBGU unit for debugging purpose on a serial com. I use it to send messages on a com to show various errors in the processing flow.

I use the Saiberion method which share the PIT interrupt for the kernel tick and the DBGU interface. It doesn’t seem to make difficulties on the com processing, but I don’t use it for an application communication interface.

By the way, this com has limitation and you will be stuck to an 8 bytes with parity format. The baud rate generator is also more simple, and there is no more rs485, irda, iso7816 mode.

As for the FreeRTOSconfig.h, this DBGU is quite specific for atsam7x. Is it a good idea to insert quite a specific purpose on a more general project like FreeRTOS ? Perhaps a good application example should be enough.