Error on C18 port?

darukur wrote on Sunday, October 19, 2008:

Hello all,

I´ve been dealing some time with different errors in FreeRTOS with C18 port.

Looking in the port i´ve found this:

#pragma code high_vector=0x08
static void prvLowInterrupt( void )
{
    /* Was the interrupt the tick? */
    if( PIR1bits.CCP1IF )
    {       
        _asm
            goto prvTickISR
        _endasm
    }

    /* Was the interrupt a byte being received? */
    if( PIR1bits.RCIF )
    {
        _asm
            goto vSerialRxISR
        _endasm
    }

    /* Was the interrupt the Tx register becoming empty? */
    if( PIR1bits.TXIF )
    {
        if( PIE1bits.TXIE )
        {
            _asm
                goto vSerialTxISR
            _endasm
        }
    }
}
#pragma code

In accordance with C18 manual the pragma code place obviously code in the specified direction, but in the case of the interrupt it´s mean to be used just for a computed goto to the isr routine because the next positions (0x18) are mean for the low interrupt service.
I think the previous code is writing beyond his range, also if you want to use priority level it definitely wont fit.

Here I post a modified example:

#pragma code high_vector=0x08
static void highIsr( void )
{
        _asm
            goto prvHighInterrupt
        _endasm
}
#pragma code

#pragma code low_vector=0x18
static void lowIsr( void )
{
        _asm
            goto prvLowInterrupt
        _endasm
}
#pragma code

#pragma interrupt prvHighInterrupt //save=PRODH, PRODL, TABLAT, section(".tmpdata")
static void prvHighInterrupt( void )
{
    /*Timer Related Interrupt*/
    if( PIR1bits.CCP1IF )
    {       
        _asm
            goto prvTickISR
        _endasm
    }
}

#pragma interruptlow prvLowInterrupt //save=PRODH, PRODL, TABLAT, section(".tmpdata")
static void prvLowInterrupt( void )
{
    /* Was the interrupt a byte being received? */
    if( PIR1bits.RCIF )
    {
        _asm
            goto vSerialRxISR
        _endasm
    }

    /* Was the interrupt the Tx register becoming empty? */
    if( PIR1bits.TXIF )
    {
        if( PIE1bits.TXIE )
        {
            _asm
                goto vSerialTxISR
            _endasm
        }
    }
}

Two more method def are required prvHighInterrupt and prvLowInterrupt.

Regards

davedoors wrote on Monday, October 20, 2008:

PIC18? - eek.

darukur wrote on Monday, October 20, 2008:

Yeap, PIC18 with MCC18.
Does anyone have a newer working example for this micro?
I mean MCC18 3.2 FreeRTOS 5.0.4 and a new micro (like PIC18F2620).
I can not manage to get it working properly with this micro and compiler.
In some point I always get a stack under-over flow reset or a read over a wrong code place.