grantkbrown wrote on Tuesday, 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 FPLLMUL = MUL_20, FPLLIDIV = DIV_2, FPLLODIV = DIV_1, FWDTEN = OFF
#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
// SYSTEMConfigPerformance(80000000);
prvSetupHardware();
// configure the port registers
PORTSetPinsDigitalOut(IOPORT_D, BIT_0|BIT_1|BIT_2);
// initialize the port pin states = outputs low
mPORTDClearBits(BIT_0|BIT_1|BIT_2);
if(xTaskCreate( &GrantsTask, "GKB_Tsk", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL ) == pdPASS)
{
PORTSetBits(IOPORT_D,BIT_1);
}
else
{
PORTSetBits(IOPORT_D,BIT_0);
}
// start the scheduler. */
vTaskStartScheduler();
// Will only reach here if there is insufficient heap available to start the scheduler
while(1)
{
if(++Cnt == 65000)
{
mPORTDToggleBits(BIT_2);
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();
while(1)
{
vTaskDelay(xFrequency);
mPORTDToggleBits(BIT_2);
}
}
/*-----------------------------------------------------------*/
static void prvSetupHardware( void )
{
/* Set the system and peripheral bus speeds and enable the program cache*/
SYSTEMConfigPerformance( configCPU_CLOCK_HZ - 1 );
mOSCSetPBDIV( OSC_PB_DIV_2 );
/* Setup to use the external interrupt controller. */
INTEnableSystemMultiVectoredInt();
portDISABLE_INTERRUPTS();
/* Setup the digital IO for the LED’s. */
// vParTestInitialise();
}
/*-----------------------------------------------------------*/
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( ;; );
}