Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


P&E ICD Resetting for HCS12 Banked

Posted by gisthandler on June 6, 2012
So I've been working on the HCS12 Banked coding and have gotten two of my testing tasks to compile. However, when I'm running it through the Multilink USB on the Codewarrior debugger, I have to keep pressing Start/Continue or the reset button on the microcontroller in order for the task to run. Any suggestions?


RE: P&E ICD Resetting for HCS12 Banked

Posted by Erich Styger on June 6, 2012
Hard to tell with the information given. But could it be that you have the watchdog enabled? Then you will get a watchdog reset and the debugger will show you the startup code (if you are not resetting the watchdog timer properly).
Does it work for you in non-banked memory model?
And do you say it works without the debugger? Without the debugger and if the watchdog triggers your board will simply reset so you might not notice what happend.
I remember I have fixed several items for the banked memory model in the port on http://mcuoneclipse.wordpress.com/2012/02/11/back-to-classic-freertos-for-freescale-s12x/.


RE: P&E ICD Resetting for HCS12 Banked

Posted by gisthandler on June 6, 2012
It turns out the tasks runs after I exit from the debugger and press reset. However, only one of my two tasks are working:

/*IR sensor for object detection*/
xTaskCreate( prvTestTask1, "A2D_INPUT", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 3, NULL );
/*Motor control*/
xTaskCreate( prvTestTask2, "MOTOR_INPUT", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 3, NULL );

When both of the task's priority's are the same only, "MOTOR_INPUT" will work. However, if I set the priority of "A2D_INPUT" higher, then the "A2D_TASK" will work, but the other one won't. Any suggestions?


RE: P&E ICD Resetting for HCS12 Banked

Posted by Dave on June 7, 2012
When both priorities are the same the scheduler will time slice both tasks (round robin with time slicing). When one task has a priority higher than the other then the scheduler will run the highest priority task whenever the high priority task can run. The high priority task can run if it is not blocked or suspended. I assume then that your A2D_INPUT task never blocks, but you have not posted its code, so I cannot be certain. Does it ever block on a queue or semaphore, or ever call vTaskDelay() or vTaskDelayUntil()?

RE: P&E ICD Resetting for HCS12 Banked

Posted by gisthandler on June 7, 2012
I have added the vTaskDelay for the A2D_INPUT task, but haven't added it on the MOTOR_INPUT. Does vTaskDelay() and vTaskDelayUntil() help set and release the mutex locks?



static void prvTestTask1( void *pvParameters )
for( ;; )
while (!(ATD1STAT0)){} /*Waits for A2D to be ready*/
read_value = ATD1DR0; /*Reads voltage*/
display = read_value/200; /*Converts approximate digital reading*/
if(display < 4) { /*Vinput = 5 V*/
PORTA = 0x01; /*If less than 4 volts, light LED*/
} else{
PORTA = 0x00;
ATD1CTL5 = 0x80; /*Reset A2D*/
vTaskDelay( mediumDelay );

static void prvTestTask2( void *pvParameters )
for( ;; )
pulse(); /*Sets high and low*/
delay(300); /*based on flag and delay using IOC0*/

RE: P&E ICD Resetting for HCS12 Banked

Posted by MEdwards on June 7, 2012
I can't see any mutexes in your code? Can you explain?

In the code you poste, if prvTestTask1 is the higher priority task then it should be ok. If prvTestTask2() is the higher priority task then prvTestTask1 will never execute because prvTestTask2 will run all the time.

[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]

Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


FreeRTOS and other embedded software careers at AWS.

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers


STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner