Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

PIC18F FreeRTOS interrupt switch context

Posted by mengfick on June 11, 2015

Hello,

I'am doing a project about the CAN bus using the FreeRTOS in PIC18F, but I face with a problem in the interrupt;

The PIC18 does allow two priorities of interrupt. The project is set up to use compatibility mode, so I make my own routine of interrupt for receiving the message in bus CAN, just after the routine of prvTickISR, and the problem is that if I switch the context in the routine, PIC18 will not receive the message, the program will entrer the block of vListRemove() and vListInsert() (in fonction of vTaskIncrementTick() -> prvCheckDelayedTasks();), and I see that the number of the list is so big, about 0x69, but I just have three tasks;

I don't understand why in the routine prvTickISR, it works to switch the context, but in my own routine, il doesn't work at all.

Thanks in advance four your attention and work.

static void prvTickISR( void ) { /* Interrupts must have been enabled for the ISR to fire, so we have to save the context with interrupts enabled. */ portSAVECONTEXT( portGLOBALINTERRUPT_FLAG ); PIR3bits.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();

}

the routine like that doesn't work: static void vCANRxISR (void) { portSAVECONTEXT(portGLOBALINTERRUPT_FLAG); PIR5bits.RXB0IF = 0;

xSemaphoreGiveFromISR(xBinarySemaphoreCANRecv,&xHigherPriorityTaskWoken);

vTaskSwitchContext();

portRESTORE_CONTEXT();  

} static void vCANRxISR (void) {

PIR5bits.RXB0IF = 0;

xSemaphoreGiveFromISR(xBinarySemaphoreCANRecv,&xHigherPriorityTaskWoken);

taskYield(); 

}

the routine like that work fine: static void vCANRxISR (void) { PIR5bits.RXB0IF = 0;

xSemaphoreGiveFromISR(xBinarySemaphoreCANRecv,&xHigherPriorityTaskWoken);

}


PIC18F FreeRTOS interrupt switch context

Posted by rtel on June 11, 2015

The PIC18 is really not a good architecture for a pre-emptive OS.

There is an example ISR provided, which is called vSerialRxISR(), and is found in the FreeRTOSDemoPIC18_MPLABserial directory. I don't think your code is following the same scheme.

Regards.


PIC18F FreeRTOS interrupt switch context

Posted by mengfick on June 11, 2015

PIC18F FreeRTOS interrupt switch context

Posted by mengfick on June 11, 2015

Thanks for your reply. Yes, I have refered the exemple ISR vSerialRxISR(), and follow the same scheme, it works. But I want to know why the ISR prvTickISR() can switch the context, but in my own routine, if I use the context swtich, it doesn't work ? and I have confirmed that is not the reason of stack overflow Besides the banking memory of the PIC18, there are other reasons that the pic18 is not good for a pre-emptive OS ? Regards


PIC18F FreeRTOS interrupt switch context

Posted by rtel on June 11, 2015

Sorry - from a quick look at the code, I'm not sure either. I would suggest stepping through the interrupt from entry to exit to see if that highlights any clues.


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




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists