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


Code crach when adding FreeRTOS to PIC32MX795

Posted by Karen on July 22, 2013
Hope it is the right place asking FreeRTOS related question using PIC32MX795F512L.

I am new to PIC32.

I made four external interrups (INT1 to INT4) and CAN 1 working properly on the board (not start kit, I don't have start kit). Then I added FreeRTOS to the code. The issue is that after adding FreeRTOS, the code always crashes as soon as calling vTaskStartScheduler(). I noticed that if I only made the CAN 1 running, it works ok, as long as enabling external interrupts, even just one, the software crash. On the PIC32, I also set up PWM to output clocks and setup 4 SPI buses (setup to master), but there is no interrupts on SPI bus.

This is the external interrupt routine, all four external interrupts have almost the same code except line msg.data[0] = 0;

/* Meter 1 IRQ */
void __ISR(_EXTERNAL_1_VECTOR, ipl3) INT1Interrupt(void)
struct ipc_message msg;
portBASE_TYPE err;

if(mPORTEReadBits(BIT_8) == 0) {
/* Disable further interrupt from INT1 since need to process interrupt */
msg.data[0] = 0; /* task uses zero-based */
err = xQueueSendToBackFromISR(meters_ipc.ipc_inbox, &msg, NULL);
if(err == errQUEUE_FULL) {
meters_ipc.ipc_overflow = 1;
} else {
if(meters_ipc.ipc_overflow == 1)
meters_ipc.ipc_overflow = 0;

on FreeRTOSConfig.h, defined:

/* The priority at which the tick interrupt runs. This should probably be
kept at 1. */

/* The maximum interrupt priority from which FreeRTOS.org API functions can
be called. Only API functions that end in ...FromISR() can be used within
interrupts. */

I also setup

#pragma config FPLLMUL = MUL_20 /* In DEVCFG2 */
#pragma config FPLLIDIV = DIV_2 /* In DEVCFG2 */
#pragma config FPLLODIV = DIV_1 /* In DEVCFG2 */
#pragma config FWDTEN = OFF
#pragma config POSCMOD = HS /* In DEVCFG1 */
#pragma config FNOSC = PRIPLL /* In DEVCFG1 */
#pragma config FPBDIV = DIV_1 /* In DEVCFG1 */
/* code protect, boot write protect, flash write protect */
#pragma config CP = OFF, BWP = OFF, PWP = OFF
#pragma config UPLLEN = OFF
#pragma config FSRSSEL = PRIORITY_7

At the beginning of the main() loop, I called:


any problem on it?

Very appreciate for the help.


RE: Code crach when adding FreeRTOS to PIC32MX795

Posted by MEdwards on July 22, 2013
You need some simple wrappers on your ISR. Look at the Interrupt Service Routines section on this page for an example http://www.freertos.org/port_PIC32_MIPS_MK4.html

Then with the settings you show in your post make sure the interrupt priority is 3 or below.

[ 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