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


Exception after adding global array

Posted by bnrtos on April 20, 2011
Forgive the newbiancy, but I've just added a global array to my PIC32 project. e.g. buffer[BUFFER_SIZE]; I've already got several tasks and the project works great however when BUFFER_SIZE is increased above a few hundred bytes or so, it seems a couple tasks no longer execute and I end up in the exception handler with a databus error.

I've got the stack overflow set with a breakpoint in that hook and I've increased the heap size and all task sizes several times to no avail.

Suggestions appreciated!

RE: Exception after adding global array

Posted by Dave on April 21, 2011
Have you checked that the tasks are actually created successfully? Look at the return value of xTaskCreate(), and if you are using heap_1.c or heap_2.c (not sure about heap_3.c, but maybe that too) then define a malloc failed hook to see if any allocations fail.

Also check the linker script/map file to ensure you are using the right memory layout for the PIC32 chip you are using.

RE: Exception after adding global array

Posted by bnrtos on April 21, 2011
Hi Dave, thanks for the reply.

- Yes, I've got traps on all the xTaskCreate() calls -- no apparent problem there.
- I'm using heap_2 and added the malloc failed hook/define but it doesn't seem to be getting hooked.
- I'm not specifying a linker script so MPLAB is defaulting ot the standard script for my PIC32.

Basically, I had a huge RTOS queue (40960 bytes) and found QueueSendToBack seemed a bit expensive so I was trying to replace it with my own circular buffer/array. I've made all the necessary changes, eliminated the queue, and defined my array buffer. Once I increase the size of my array past a couple hundred bytes, the tasks don't seem to run properly. I know that's a bit vague and it could be a multitude of things -- the point is, I'm not *using* the array in my code yet... just allocating/defining it.

If it's under a certain size, everything works fine; if not, I don't get any exceptions (that I'm aware of) but things are not fine.

If I could create a Queue of size=40960, why can't a define a native array of the same size? What's different about the Queue creation?

RE: Exception after adding global array

Posted by bnrtos on April 21, 2011
Ok, wow, sorry for wasting everyone's time. It turns out this wasn't RTOS related at all. The initializer for said array was "0" instead of "{0}" which somehow caused all sorts of havoc without any warning(s).

Thanks for your time.

[ 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