Dear FreeRTOS support,
I've made a stripped down program with the RTOS for the processor PIC32MX320F128H with a blinking LED for a test.
However, it refuses to start at all. Is there any thing I need to put inside for a bare essential RTOS to work?
Thanks.
Here's the code:
#pragma config POSCMOD=XT, FNOSC=PRIPLL
#pragma config FPLLIDIV=DIV_2, FPLLMUL=MUL_18, FPLLODIV=DIV_1
#pragma config FPBDIV=DIV_2, FWDTEN=OFF, CP=OFF, BWP=OFF
#include
#include
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "croutine.h"
#include "timers.h"
void UART1_Init();
void UART1_putc(unsigned char);
void UART1_puts(unsigned char*);
static void prvSetupHardware( void );
static void prvCheckTask( void *pvParameters ) __attribute__((noreturn));
static void vLEDTask(void* pvParameters);
const portTickType smallDelay = 500 / portTICK_RATE_MS;
unsigned long i = 0;
int main()
{
prvSetupHardware();
xTaskCreate(vLEDTask, "LED", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL );
vTaskStartScheduler();
return 0;
}
void UART1_Init()
{
U1BRG = 77;
U1MODE = 0x8008;
U1STAbits.UTXEN = 1;
U1STAbits.URXEN = 1;
}
void UART1_putc(unsigned char inputc)
{
while(U1STAbits.UTXBF);
U1TXREG = inputc;
}
void UART1_puts(unsigned char* string)
{
while(*string)
UART1_putc(*string++);
}
static void prvSetupHardware( void )
{
AD1PCFG = 0xFFFF; //All pins as Digital
DDPCONbits.JTAGEN = 0; //Disable the JTAG port
SYSTEMConfigPerformance(72000000);
mOSCSetPBDIV(OSC_PB_DIV_2);
INTEnableSystemMultiVectoredInt();
TRISE = 0x0000;
PORTE = 0x0000;
PMCONbits.ON = 0;
}
static void vLEDTask(void* pvParameters)
{
for(;;)
{
PORTEbits.RE0 ^= 1;
vTaskDelay(1000);
}
}
The LEDTask is to toggle the LED for each second, but it didn't even start.
Thanks for the support.
Did you start with the preconfigured demo provided in the FreeRTOS download, or create this from scratch?
Are the UART functions in the above code ever called in your stripped down demo?
How do you know it is not starting? If you step through the code in the debugger, how far does it get? What happens?
Have you tried your LED accessing code without the RTOS, or from main() before the RTOS is started?
Regards.
Apologies for double posting. Can't edit the previous post.
Apparently I simulated it, but when I put a breakpoint on "PORTEbits.RE0 ^= 1;", the MPLAB SIM just runs and runs without ever halting on that place.
When I placed a breakpoint on the "return 0", it immediately points on that.
Is it some stack overflow error according to the documentations?
Thanks.