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


Newbie completely lost

Posted by Grant Brown on October 21, 2008
Hi List,

Device / Port : PIC32

My project is copied below for reference.

It got the PIC32 demo running OK but now I have the following problems.

1) - I tried to slim down the project by deleting all of the demo tasks and demo files from the project and now the compiler fails to compile the project copied below.

2) - When I did have the project compiling but with the demo "Main" function commented out and running my own "Main" function I had the following problems.

My task got created - this was confirmed by checking that the return value was pdPASS

However the scheduler did not start. This was confirmed by RD2 started flashing - see code below.

So my questions are,

(a) - What are the minimal files required to compile a PIC32 project with the RTOS and a minimal task such as the one below.

(b) - With only using the task below why did the scheduler not start ?

Many thanks in advance

kind Regards
Grant Brown

/* Standard includes. */
#include <plib.h>
#include <stdio.h>

/* Scheduler includes. */
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"

#pragma config POSCMOD = HS, FNOSC = PRIPLL, FPBDIV = DIV_2

static void GrantsTask(void *pvParameters);
static void prvSetupHardware( void );
int Cnt = 0;
int main( void )

// configure the wait states and peripheral bus clock


// configure the port registers
PORTSetPinsDigitalOut(IOPORT_D, BIT_0|BIT_1|BIT_2);
// initialize the port pin states = outputs low

if(xTaskCreate( &GrantsTask, "GKB_Tsk", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL ) == pdPASS)
// start the scheduler. */
// Will only reach here if there is insufficient heap available to start the scheduler
if(++Cnt == 65000)
Cnt = 0;

return 0;

static void GrantsTask(void *pvParameters)
portTickType xLastExecutionTime;
const portTickType xFrequency = 500;
//PORTWrite(IOPORT_D, 0x05); // 0000 0000 0000 0101
xLastExecutionTime = xTaskGetTickCount();


static void prvSetupHardware( void )
/* Set the system and peripheral bus speeds and enable the program cache*/
SYSTEMConfigPerformance( configCPU_CLOCK_HZ - 1 );

/* Setup to use the external interrupt controller. */


/* Setup the digital IO for the LED's. */


void vApplicationStackOverflowHook( void )
/* Look at pxCurrentTCB to see which task overflowed its stack. */
for( ;; );

void _general_exception_handler( unsigned portLONG ulCause, unsigned portLONG ulStatus )
/* This overrides the definition provided by the kernel. Other exceptions
should be handled here. */
for( ;; );

RE: Newbie completely lost

Posted by Dave on October 21, 2008
In the first case you dont say why the code would not compile. I cannot offer advice without knowing the error message the compiler gave.

In the second case you have the code:
if(xTaskCreate( &GrantsTask,

remove the &. The first parameter is a pointer to the task function. With the & you are passing in the address of a pointer to the function.

RE: Newbie completely lost

Posted by Grant Brown on October 21, 2008

Sorroy, here are the error messages

Main.c: In function `main':
Main.c:47: error: `configMINIMAL_STACK_SIZE' undeclared (first use in this function)
Main.c:47: error: (Each undeclared identifier is reported only once
Main.c:47: error: for each function it appears in.)
Main.c:47: error: `tskIDLE_PRIORITY' undeclared (first use in this function)
Main.c:47: error: `pdPASS' undeclared (first use in this function)
Main.c: In function `GrantsTask':
Main.c:72: error: `portTickType' undeclared (first use in this function)
Main.c:72: error: syntax error before "xLastExecutionTime"
Main.c:73: error: syntax error before "xFrequency"
Main.c:75: error: `xLastExecutionTime' undeclared (first use in this function)
Main.c:78: error: `xFrequency' undeclared (first use in this function)
Main.c: In function `prvSetupHardware':
Main.c:89: error: `configCPU_CLOCK_HZ' undeclared (first use in this function)
Main.c: At top level:
Main.c:110: error: syntax error before "ulCause"
Main.c:116:64: warning: no newline at end of file
Halting build on first failure as requested.

Kind Regards
Grant Brown

[ 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