nobody wrote on Thursday, September 07, 2006:
I’m trying to build my application based on FreeRTOS+lwIP Rowley Demo.
Everything works fine with my AT91SAM7X256 board. Now I’m trying to write my own piece of code to understand how everything works.
I tried to write timer interrupt and toggle a led with it. Code worked when I compiled it without FreeRTOS but when I try to implement it as a part of the system it doesnt work.
My timer init looks like that:
void timer_init ( void )
//* Open timer0
//* Open Timer 0 interrupt
AT91F_AIC_ConfigureIt ( AT91C_ID_TC0, TIMER0_INTERRUPT_LEVEL,AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL, timer0_c_irq_handler);
AT91C_BASE_TC0->TC_IER = AT91C_TC_CPCS; // IRQ enable CPC
// AT91F_AIC_EnableIt (AT91C_BASE_AIC, AT91C_ID_TC0);
AT91C_BASE_AIC->AIC_IECR = 0x1 << AT91C_ID_TC0;
//* Start timer0
AT91C_BASE_TC0->TC_CCR = AT91C_TC_SWTRG ;
And interrupt routine:
void timer0_c_irq_handler(void) __attribute__ ((naked));
portBASE_TYPE xSwitchRequired = pdFALSE;
AT91PS_TC TC_pt = AT91C_BASE_TC0;
unsigned int dummy;
//* Acknowledge interrupt status
dummy = TC_pt->TC_SR;
//* Suppress warning variable "dummy" was set but never used
dummy = dummy;
//* Read the output state
if ( (AT91F_PIO_GetInput(AT91C_BASE_PIOB) & LED1 ) == LED1 )
AT91F_PIO_ClearOutput( AT91C_BASE_PIOB, LED1 );
AT91F_PIO_SetOutput( AT91C_BASE_PIOB, LED1 );
portEXIT_SWITCHING_ISR( xSwitchRequired );
Timer init is called from vBasicWEBServer thread.
The problem is that TimerISR is entered only once and the led flashes but then it hangs. Other tasks work fine.
I’ve lost many hours to fix it, maybe I dont understand something, but it should work and it doesnt.