Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Loading

FreeRTOS+lwIP Demo - timer int doesnt work

Posted by Nobody/Anonymous on September 7, 2006
Hi,
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 )
//* Begin
{
portENTER_CRITICAL();

//* Open timer0
AT91F_TC_Open(AT91C_BASE_TC0,TC_CLKS_MCK8,AT91C_ID_TC0);

//* 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 ;

portEXIT_CRITICAL();
//* End
}

And interrupt routine:
void timer0_c_irq_handler(void) __attribute__ ((naked));

void timer0_c_irq_handler(void)
{
portENTER_SWITCHING_ISR();

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;
count_timer0_interrupt++;
//* Read the output state
if ( (AT91F_PIO_GetInput(AT91C_BASE_PIOB) & LED1 ) == LED1 )
{
AT91F_PIO_ClearOutput( AT91C_BASE_PIOB, LED1 );
}
else
{
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.

RE: FreeRTOS+lwIP Demo - timer int doesnt work

Posted by Nobody/Anonymous on September 7, 2006
You should send info to AIC that you finished interrupt service (eg. *AT91C_AIC_EOICR = 0;) before portEXIT_SWITCHING_ISR.

Janusz

RE: FreeRTOS+lwIP Demo - timer int doesnt work

Posted by Nobody/Anonymous on September 7, 2006
Well... I'm blind %). How could I miss it while looking at EMAC_ISR example routine? :D
Thanks for help, it works now :]


[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner