FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [July 2014 Threads] Variable Defined In main() Not Accessible By Any TaskPosted by gbmhunter on July 19, 2014 I am using the PSoC 5 microcontroller and built a FreeRTOS firmware app based on the associated example.
I am having an interesting problem in where any variable I declare in main() is not accessible by a task. That is, I create a variable in main(), and then pass a pointer that points to this variable to the tasks. After calling vTaskStartScheduler(), the tasks then try and read/write to this variable, however it is invalid?
I would of thought this would be o.k., since the firmware never exits main(), this variable should be accessible.
Variable Defined In main() Not Accessible By Any TaskPosted by davedoors on July 19, 2014 PSoC 5 - is that Cortex-M3? On Cortex-M the stack that was used by main is reused as the system stack. Your variable will simple get overwritten each time there is an interrupt. If you make the variable static then it won't be on the stack and should work, but if you do that then why not just give the variable file scope so declare it outside of main?
Variable Defined In main() Not Accessible By Any TaskPosted by gbmhunter on July 19, 2014 Yes, it is the Cortex-M3. Oh thanks for that information! I wasn't aware the main() stack was shared with the system stack (I will have to look further into what that exactly means).
Yes I can make it static or the variable global, which will put it on the heap, and that is what I have been currently doing to fix it. However, I still find this concept odd to grasp, I thought a variable that had been given scope in main() would exist until main() exited, no matter what else happened.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|