Interupts priorities on PIC18
Hi all,
I´m using FreeRTOS with PIC18 and I´ve modified the port to work with priorities (High priority for the prvTickISR) and low priority for the others (like USART and I2C).
Is there any consideration to have in mind? because I´m having a strange behaviour with the task that manages the I2C that waits for the I2C semaphore to be signaled.
here the ISR code:
#pragma code high_vector=0x08
static void prvHighInterrupt( void )
{
/* Was the interrupt the tick? */
if( PIR1bits.CCP1IF )
{
_asm
goto prvTickISR
_endasm
}
}
#pragma code
#pragma code low_vector=0x18
static void prvLowInterrupt( void )
{
/*i2c interrupt*/
if( PIR1bits.SSPIF )
{
_asm
goto vI2cISR
_endasm
}
/* Was the interrupt a byte being received? */
if( PIR1bits.RCIF )
{
_asm
goto vSerialRxISR
_endasm
}
/* Was the interrupt the Tx register becoming empty? */
if( PIE1bits.TXIE && PIR1bits.TXIF )
{
_asm
goto vSerialTxISR
_endasm
}
}
#pragma code
Here the timer int hook and i2c int hook:
#pragma interrupt prvTickISR
static void prvTickISR( void )
{
/* Interrupts must have been enabled for the ISR to fire, so we have to
save the context with interrupts enabled. */
portSAVE_CONTEXT( portGLOBAL_INTERRUPT_FLAG );
PIR1bits.CCP1IF = 0;
/* Maintain the tick count. */
vTaskIncrementTick();
#if configUSE_PREEMPTION == 1
{
/* Switch to the highest priority task that is ready to run. */
vTaskSwitchContext();
}
#endif
portRESTORE_CONTEXT();
}
#pragma interruptlow vI2cISR save=PRODH, PRODL, TABLAT, section(".tmpdata")
void vI2cISR( void )
{ …..
Do I have to manage the global interrupt? (GIEH , GIEL )
Interupts priorities on PIC18
Looking at this (I try to avoid looking at anything with PIC18 in it) it seems the FreeRTOS code only uses the one priority so using both would require some effort to change the port.
Interupts priorities on PIC18
Thanks, its true.
I´ve been diggin around and the port its not optimized to use priorities.