/* Standard includes. */
#include <stdio.h>
/* Scheduler includes. */
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "croutine.h"
/* Application includes. */
#include "BlockQ.h"
#include "crflash.h"
#include "blocktim.h"
#include "integer.h"
#include "comtest2.h"
#include "partest.h"
#include "lcd.h"
#include "timertest.h"
#include "portmacro.h"
void pre_RTOS_init_hardware()
{
// e.g. setup CPU clock/PLL
// setup analog inputs
// setup uart config
// etc.
}
/**
* Watchdog task. This periodically runs (at least once a second) to
* clear the watchdog. The watchdog will reset the processor if more
* than one second elapses between watchdog events. The watchdog has
* a very high priority level but it only executes every 500ms.
*/
void vWatchdogTask(void *pvParameters)
{
for(;;)
{
// Here we would clear the WDT (TODO.)
vTaskDelay(500 / portTICK_RATE_MS);
}
}
/**
* Idle hook. This doesn't execute anything.
* TODO: Low power mode.
*/
void vApplicationIdleHook()
{
vCoRoutineSchedule();
}
int main()
{
// Set up the hardware (before the RTOS scheduler starts.)
pre_RTOS_init_hardware();
// Create the watchdog task. This periodically clears the WDT.
xTaskCreate(vWatchdogTask, (signed char*) "Watchdog", 16, NULL, 0, NULL );
// Start the scheduler. This function should not return as it causes the execution
// context to change from main() to one of the created tasks.
vTaskStartScheduler();
// Should never get here.
while(1);
return 0;
}
The crash:
CORE-E0002: Trap due to misaligned data word access, occurred from instruction at 0x001de8
CORE-E0003: Trap due to unimplemented RAM memory access, occurred from instruction at 0x001de8
CORE-E0001: Trap due to stack error, occurred from instruction at 0x001de8
CORE-W0008: Software Reset Instruction called at PC=0x0002be
I’m sure I must have missed something out but I can’t think what it is. If more info is needed please let me know.
ThanksTom