Quality RTOS & Embedded Software

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




Loading

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 */
disable_mcu_INT(1);
msg.command = IPC_INTERRUPT_REQUEST;
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. */
#define configKERNEL_INTERRUPT_PRIORITY 0x01

/* 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. */
#define configMAX_SYSCALL_INTERRUPT_PRIORITY 0x03

I also setup

/* SYSCLK = 80 MHz (8MHz Crystal/ FPLLIDIV * FPLLMUL / FPLLODIV) */
#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:

SYSTEMConfig(SYS_CLOCK, SYS_CFG_WAIT_STATES | SYS_CFG_PCACHE);

any problem on it?

Very appreciate for the help.

Karen


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) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

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

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

OpenRTOS and SafeRTOS