PIC24 interrupt

amarjith wrote on Tuesday, November 05, 2013:

On an interrupt routine I’ll have to use:

I’m using Binary Semaphores for interrupt synchronization.

as state on the FreeRTOS book:

The syntax of the interrupt service routine declaration and the macro called to force a context switch
are both specific to the Open Watcom DOS port and will be different for other ports. Please refer to
the examples that are included in the demo application for the port being used to find the actual syntax
required.

static void __interrupt __far vExampleInterruptHandler( void )
{
static portBASE_TYPE xHigherPriorityTaskWoken;
xHigherPriorityTaskWoken = pdFALSE;
/* ‘Give’ the semaphore to unblock the task. /
xSemaphoreGiveFromISR( xBinarySemaphore, &xHigherPriorityTaskWoken );
if( xHigherPriorityTaskWoken == pdTRUE )
{
/
Giving the semaphore unblocked a task, and the priority of the
unblocked task is higher than the currently running task - force
a context switch to ensure that the interrupt returns directly to
the unblocked (higher priority) task.
NOTE: The actual macro to use to force
ISR is dependent on the port. This is
Open Watcom DOS port. Other ports may
Refer to the examples provided for the
the syntax required. */
portSWITCH_CONTEXT();
a context switch from an
the correct macro for the
require different syntax.
port being used to determine
}
}

As such portSWITCH_CONTEXT is port dependent. I cannot find this function in the port of pic24F and interrupt handler function static void __interrupt __far vExampleInterruptHandler( void ),

__asm{ int 0x82 } this line generates the interrupt.

/* Install the interrupt handler. */
_dos_setvect( 0x82, vExampleInterruptHandler );

Could you please explain this in detail to me.

rtel wrote on Tuesday, November 05, 2013:

Please refer to the examples that are included in the demo application for
the port being used to find the actual syntax required.

This is the documentation page for the PIC24:

If you look at the “Interrupt Service Routines” section you will see it is actually much simpler on the PIC24. The demo in the FreeRTOS download (referenced from the same page) contains an example.

Regards.

amarjith wrote on Tuesday, November 05, 2013:

Thank you so much sir. yes, i got it i have changed my code like this

void attribute((interrupt, auto_psv)) _ExampleInterruptHandler( void )
{
static portBASE_TYPE xHigherPriorityTaskWoken;
xHigherPriorityTaskWoken = pdFALSE;
/* ‘Give’ the semaphore to unblock the task. /
xSemaphoreGiveFromISR( xBinarySemaphore, &xHigherPriorityTaskWoken );
if( xHigherPriorityTaskWoken == pdTRUE )
{
/
Giving the semaphore unblocked a task, and the priority of the
unblocked task is higher than the currently running task - force
a context switch to ensure that the interrupt returns directly to
the unblocked (higher priority) task.
NOTE: The actual macro to use to force
ISR is dependent on the port. This is
Open Watcom DOS port. Other ports may
Refer to the examples provided for the
the syntax required. */
taskYIELD();

}

}

No errors now.

Could you clarify these lines too,

__asm{ int 0x82 } this line generates the interrupt.

/ Install the interrupt handler. /
_dos_setvect( 0x82, vExampleInterruptHandler );

i cannot find Install the interrupt handler.in demo.

rtel wrote on Tuesday, November 05, 2013:

Could you clarify these lines too,

They are only relevant to the x86 port, not the PIC24 port.

Regards.

amarjith wrote on Tuesday, November 05, 2013:

Ok. how i Install the interrupt handler in pic24. could you say the equivalent code in pic24?

rtel wrote on Tuesday, November 05, 2013:

As per the documentation page - interrupts are installed using the standard compiler syntax described in the compiler manual, and there is an example in \FreeRTOS\Demo\PIC24_MPLAB\serial\serial.c.

Regards.