i wrote this program for test:
in port.c:
void SIG_OUTPUT_COMPARE1A( void ) __attribute__ ( ( signal, naked ) );
void SIG_OUTPUT_COMPARE1A( void )
{
PORTA++;vPortYieldFromTick();PORTA--;
asm volatile ( "reti" );
}
=================================================================
/* Priority definitions for most of the tasks in the demo application. Some
tasks just use the idle priority. */
#define mainLED_TASK_PRIORITY ( tskIDLE_PRIORITY )
void LED1( void *pvParameters )
{
DDRB = 0xff;
while(1)
{
PORTB |= (1<<0);
_delay_us(1);
PORTB &= ~(1<<0);
_delay_us(1);
}
}
void LED2( void *pvParameters )
{
DDRC = 0xff;
while(1)
{
PORTC |= (1<<1);
_delay_us(1);
PORTC &= ~(1<<1);
_delay_us(1);
}
}
portSHORT main(void)
{
DDRA=0xff;
PORTD++;
xTaskCreate( LED1, ( signed char * ) "LED1", 100, NULL, 0, NULL );
xTaskCreate( LED2, ( signed char * ) "LED2", 100, NULL, 0, NULL );
vTaskStartScheduler();
return 0;
}
note that i used PORTA to see timer interrupt flow.after simulating i got this result on output:
![](http://s1.picofile.com/file/7789626555/test_1.jpg)
if you change timer interrupt in ‘port.c’ file to this :
void SIG_OUTPUT_COMPARE1A( void ) __attribute__ ( ( signal, naked ) );
void SIG_OUTPUT_COMPARE1A( void )
{
asm volatile ( "sei" );
PORTA++;vPortYieldFromTick();PORTA--;
asm volatile ( "reti" );
}
you will see this result :![](http://s2.picofile.com/file/7789631612/test_2.jpg)
you can see that the program loops in interrupt handler until next interrupt tick and there are an overlap on firing interrupt.
but both task are working and we have auto switch between tasks.