Quality RTOS & Embedded Software

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


Loading

machine resetting with two tasks PIC24 family

Posted by Brian Carver on November 8, 2009
I have been having problems with scheduler running properly.

If I have one task (flash the led) it runs fine. But if I add two tasks (led and uart) the machine resets at PC zero. I set a breakpoint in the function void vTaskIncrementTick( void ) and watch the xTickCount variable.

What happens, I start the machine running it increments the xTickCount to 2 and then resets the PC down to zero and starts all over again.

I took the standard project got it running on the demo board and stripped it down the simplest form: (croutine.c, heap_1.c, list.c, port.c, portasm_PIC24.S, queue.c, tasks.c, FreeRTOSConfig.h) I have added two additional files main.c and uart.c.

So there is something I missing in my setup to get the scheduler to run properly and being able to switch between tasks.

I have disable the watchdog timers and brown-out resets.

Suggestions on where to look?

Here is my config info:

#define configUSE_PREEMPTION1
#define configUSE_IDLE_HOOK1
#define configUSE_TICK_HOOK0
#define configTICK_RATE_HZ( ( portTickType ) 1000 )
#define configCPU_CLOCK_HZ( ( unsigned portLONG ) 16000000 ) /* Fosc / 2 */
#define configMAX_PRIORITIES( ( unsigned portBASE_TYPE ) 4 )
#define configMINIMAL_STACK_SIZE( 24 )
#define configTOTAL_HEAP_SIZE( ( size_t ) 512 )
#define configMAX_TASK_NAME_LEN( 4 )
#define configUSE_TRACE_FACILITY0
#define configUSE_16_BIT_TICKS1
#define configIDLE_SHOULD_YIELD1






RE: machine resetting with two tasks PIC24 family

Posted by Dave on November 9, 2009
Is the UART interrupt priority equal to or below configKERNEL_INTERRUPT_PRIORITY?

RE: machine resetting with two tasks PIC24 family

Posted by avi asaf on November 9, 2009
try to work only with the uart task and if its also happened, its because of corruption of the uart task

and not because of 2 task that are running simultaneously

RE: machine resetting with two tasks PIC24 family

Posted by Brian Carver on November 9, 2009
At the suggestion of the UART I went and disable the UART code. It's really a loop to dump a character to the UART to test that the port is writing and I had not enabled the interrupts. So I changed the task code to turn on the LED in my UART task and turn off the LED in the led Flash task. I am not addressing the UART port at all this code.

When I run two tasks, the machine does reset and the PC does reset to zero. I am using a PIC24F16KA102. I had a similar post that the task counter was not incrementing.

I have gone back in the code I can see TMR1 being set as the TASK interrupt.

I think in moving the code over for this chip, I don't have everything configured correctly so the task management is not working correctly. Any other ideas?

RE: machine resetting with two tasks PIC24 family

Posted by Brian Carver on November 9, 2009
I went and removed all my UART related code, then I added a second LED to flash in my 2nd flash task. I built the code using one task switching between the two tasks and both versions work correctly. The LED flash delay is different in the two tasks.

I enable both tasks at the same time, neither one works correctly together.

Now I have configured the task to use a small stack:
#define configMINIMAL_STACK_SIZE( 24 )
So it must be the way the machine is setup in the config or the port.

RE: machine resetting with two tasks PIC24 family

Posted by Richard on November 9, 2009
I've just looked at the demo for the PIC24 and configMINIMAL_STACK_SIZE is set to 115. I should not set it lower than that. I would expect and almost immediate crash with it set to 24 (unless you have stack checking switched on, in which case I would expect the stack check to almost immediately flag an error).

Regards.

RE: machine resetting with two tasks PIC24 family

Posted by Brian Carver on November 9, 2009
Richard and All, I appreciate the help. The stack size was too small. I moved it back to the original 115 ( I had moved it smaller because of a compile issue) and my heap back to 1024. It works correctly. This is also the same root cause of why I was not getting the DelayUntil function working.


[ 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.


Careers

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

Renesas

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