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




Loading

Task Not Launching / LED Not Flashing

Posted by rog57 on December 19, 2012
Hi,

I've managed to modify this example program to compile:
FreeRTOSV7.3.0\FreeRTOS\Demo\CORTEX_LPC1768_IAR

I have also added CMSIS library files that I require and everything seems to compile OK. One of the files added is
"debug_frmwrk.h" that allows me to add debug statements to output on the UART0 port of the device. This too is working.

I have removed any of the code associated with the web server and USB, just leaving in the code for the LED flashing task.
I've palced DBG statements in the code so I can see how far it's getting. The code gets into the function "vTaskStartScheduler", up to line AFTER this function call:

portCONFIGURE_TIMER_FOR_RUN_TIME_STATS();

It executes that function, and that's the end of it. The LED's do not flash. In the function "vParTestInitialise", I can enable the LED's on my board to be ON or OFF to start, but they stay in the initialized state. Below is the code from "main" if it helps

Can someone please advise on what to try next.

Thank you, regards,
Gary

****************************************************************************************************************************
/* Scheduler includes. */
#include "FreeRTOS.h"
#include "task.h"
/* Demo app includes. */
#include "BlockQ.h"
#include "integer.h"
#include "blocktim.h"
#include "flash.h"
#include "partest.h"
#include "semtest.h"
#include "PollQ.h"
#include "GenQTest.h"
#include "QPeek.h"
#include "recmutex.h"

//gr includes
#include "debug_frmwrk.h"
#include "lpc17xx.h"

/*-----------------------------------------------------------*/

/* The time between cycles of the 'check' functionality (defined within the
tick hook). */
#define mainCHECK_DELAY( ( portTickType ) 5000 / portTICK_RATE_MS )

/* The toggle rate for the LED. */
#define mainLED_TOGGLE_RATE( ( portTickType ) 1000 / portTICK_RATE_MS )

/* Task priorities. */
#define mainQUEUE_POLL_PRIORITY( tskIDLE_PRIORITY + 2 )
#define mainSEM_TEST_PRIORITY( tskIDLE_PRIORITY + 1 )
#define mainBLOCK_Q_PRIORITY( tskIDLE_PRIORITY + 2 )
#define mainUIP_TASK_PRIORITY( tskIDLE_PRIORITY + 3 )
#define mainFLASH_TASK_PRIORITY( tskIDLE_PRIORITY + 2 )
#define mainINTEGER_TASK_PRIORITY ( tskIDLE_PRIORITY )
#define mainGEN_QUEUE_TASK_PRIORITY( tskIDLE_PRIORITY )

/* The WEB server has a larger stack as it utilises stack hungry string
handling library calls. */

/* The message displayed by the WEB server when all tasks are executing
without an error being reported. */
#define mainPASS_STATUS_MESSAGE"All tasks are executing without error."

/*-----------------------------------------------------------*/

/*
* Configure the hardware for the demo.
*/
static void prvSetupHardware( void );

/*
* Very basic task that does nothing but use delays to flash an LED.
*/
static void prvFlashTask( void *pvParameters );

/*-----------------------------------------------------------*/

int main( void )
{
debug_frmwrk_init();
_DBG_("Initialized");
/* Configure the hardware for use by this demo. */
prvSetupHardware();

/* Start the standard demo tasks. These are just here to exercise the
kernel port and provide examples of how the FreeRTOS API can be used. */
vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
vCreateBlockTimeTasks();
vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
vStartIntegerMathTasks( mainINTEGER_TASK_PRIORITY );
vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY );
vStartQueuePeekTasks();
vStartRecursiveMutexTasks();
_DBG_("Demo tasks started.");

/* Create the simple LED flash task. */
xTaskCreate( prvFlashTask, ( signed char * ) "Flash", configMINIMAL_STACK_SIZE, ( void * ) NULL, mainFLASH_TASK_PRIORITY, NULL );
_DBG_("xTask created.");

/* Start the scheduler. */
vTaskStartScheduler();

/* Will only get here if there was insufficient memory to create the idle
task. The idle task is created within vTaskStartScheduler(). */
for( ;; );
}
/*-----------------------------------------------------------*/

void vApplicationTickHook( void )
{
static unsigned long ulTicksSinceLastDisplay = 0;

_DBG_("In vApplicationTickHook.");

/* Called from every tick interrupt as described in the comments at the top
of this file.

Have enough ticks passed to make ittime to perform our health status
check again? */
ulTicksSinceLastDisplay++;
if( ulTicksSinceLastDisplay >= mainCHECK_DELAY )
{
/* Reset the counter so these checks run again in mainCHECK_DELAY
ticks time. */
ulTicksSinceLastDisplay = 0;

/* Has an error been found in any task? */
if( xAreGenericQueueTasksStillRunning() != pdTRUE )
{
_DBG_("An error has been detected in the Generic Queue test/demo.");
}
else if( xAreQueuePeekTasksStillRunning() != pdTRUE )
{
_DBG_("An error has been detected in the Peek Queue test/demo.");
}
else if( xAreBlockingQueuesStillRunning() != pdTRUE )
{
_DBG_("An error has been detected in the Block Queue test/demo.");
}
else if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )
{
_DBG_("An error has been detected in the Block Time test/demo.");
}
else if( xAreSemaphoreTasksStillRunning() != pdTRUE )
{
_DBG_("An error has been detected in the Semaphore test/demo.");
}
else if( xArePollingQueuesStillRunning() != pdTRUE )
{
_DBG_("An error has been detected in the Poll Queue test/demo.");
}
else if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
{
_DBG_("An error has been detected in the Int Math test/demo.");
}
else if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )
{
_DBG_("An error has been detected in the Mutex test/demo.");
}
}
}
/*-----------------------------------------------------------*/

static void prvFlashTask( void *pvParameters )
{
_DBG_("In prvFlashTask.");

portTickType xLastFlashTime;

/* We need to initialise xLastFlashTime prior to the first call to
vTaskDelayUntil(). */
xLastFlashTime = xTaskGetTickCount();

for(;;)
{
/* Simply toggle the LED between delays. */
vTaskDelayUntil( &xLastFlashTime, mainLED_TOGGLE_RATE );
vParTestToggleLED( 0 );
}
}
/*-----------------------------------------------------------*/


void prvSetupHardware( void )
{
_DBG_("In prvSetupHardware.");
/* Configure the LEDs. */
vParTestInitialise();
}

/*-----------------------------------------------------------*/

void vApplicationStackOverflowHook( xTaskHandle pxTask, signed char *pcTaskName )
{
_DBG_("In vApplicationStackOverflowHook.");

/* This function will get called if a task overflows its stack. */

( void ) pxTask;
( void ) pcTaskName;

for( ;; );
}
/*-----------------------------------------------------------*/

void vConfigureTimerForRunTimeStats( void )
{
const unsigned long TCR_COUNT_RESET = 2, CTCR_CTM_TIMER = 0x00, TCR_COUNT_ENABLE = 0x01;

_DBG_("In vConfigureTimerForRunTimeStats.");

/* This function configures a timer that is used as the time base when
collecting run time statistical information - basically the percentage
of CPU time that each task is utilising. It is called automatically when
the scheduler is started (assuming configGENERATE_RUN_TIME_STATS is set
to 1). */

/* Power up and feed the timer. */
LPC_SC->PCONP |= 0x02UL;
LPC_SC->PCLKSEL0 = (LPC_SC->PCLKSEL0 & (~(0x3<<2))) | (0x01 << 2);

/* Reset Timer 0 */
LPC_TIM0->TCR = TCR_COUNT_RESET;

/* Just count up. */
LPC_TIM0->CTCR = CTCR_CTM_TIMER;

/* Prescale to a frequency that is good enough to get a decent resolution,
but not too fast so as to overflow all the time. */
LPC_TIM0->PR = ( configCPU_CLOCK_HZ / 10000UL ) - 1UL;

/* Start the counter. */
LPC_TIM0->TCR = TCR_COUNT_ENABLE;
_DBG_("Exiting vConfigureTimerForRunTimeStats.");

}
/*-----------------------------------------------------------*/




RE: Task Not Launching / LED Not Flashing

Posted by MEdwards on December 19, 2012
I don't think you issue is FreeRTOS related (yet) because xPortStartScheduler is not called called after portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() is called.

If portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() is causing a problem then just remove the run time stats for now. Set configGENERATE_RUN_TIME_STATS to 0 and remove the definitions of portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and portGET_RUN_TIME_COUNTER_VALUE().

Do you get into xPortStartScheduler then?

Are any of the drivers you are using making use of the heap?

RE: Task Not Launching / LED Not Flashing

Posted by rog57 on December 19, 2012
Hi,
Thanks again!

I should mention that I have read the RTOS page on: http://www.freertos.org/RTOS-Cortex-M3-M4.html

I had modified the startup file to include a start-up reset handler that included a call to systemInit(), but now changed that back to the original "cstartup_M.s" and simply added a call in main to systemInit(). Now the program compiles, runs and is getting into the function "vApplicationTickHook"

The debug statement is telling me it gets to here:
/* Has an error been found in any task? */
if( xAreGenericQueueTasksStillRunning() != pdTRUE )
{
_DBG_("An error has been detected in the Generic Queue test/demo.");
}

Also, I do not use any drivers (unless that includes the UART); I've only included the header file "debug_frmwrk.h" that sends stuff out the UART.

Regards,
Gary


_DBG_("Setting: xSchedulerRunning = pdTRUE");

xSchedulerRunning = pdTRUE;
xTickCount = ( portTickType ) 0U;

/* If configGENERATE_RUN_TIME_STATS is defined then the following
macro must be defined to configure the timer/counter used to generate
the run time counter time base. */
portCONFIGURE_TIMER_FOR_RUN_TIME_STATS();

/* Setting up the timer tick is hardware specific and thus in the
portable interface. */
if( xPortStartScheduler() != pdFALSE )
{
/* Should not reach here as if the scheduler is running the
function will not return. */
_DBG_("In: xPortStartScheduler() != pdFALSE");
}
else
{
/* Should only reach here if a task calls xTaskEndScheduler(). */
_DBG_("In: (else) xPortStartScheduler() != pdFALSE");
}
}

_DBG_("Bailing out.");
I've set run_time_stats define to 0 so it won't run.


RE: Task Not Launching / LED Not Flashing

Posted by rog57 on December 19, 2012
Hi,
It's working !!!! 8~)

Now I can continue reading Richard berry's books:
"Using the FreeRTOS Real Time Kernel - A Practical Guide.pdf"
and
"FreeRTOS Reference Manual.pdf"

I will now be able to test code as I go through the book.

Thank you!
Gary






[ 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