- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am trying to use CY_NOINIT to not initialize a variable after soft reset conditions. I keep getting "reset = 0" message from UART. Am I missing something?
#include <project.h>
static uint8 is_soft_reset CY_NOINIT;
void app_init(void)
{
UART_1_Start();
if(!is_soft_reset) {
UART_1_PutString("reset = 0\n");
CyDelay(1000);
is_soft_reset = 1;
CySoftwareReset();
}
UART_1_PutString("reset = 1\n");
}
int main(void)
{
app_init(); for(;;) { }
}
- Labels:
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Put away the "static".
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I remember that global variables are always initialized to 0, even when the programmer does not initialize it explicitly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Carlos, there is a .NOINIT area which is explicitly used for variables that are not initialized to zero at reset.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My fault, didn't knew about that section ;(, just search about it and found a couple of interesting pages describing it:
* http://stackoverflow.com/questions/11180892/force-gcc-to-forgo-zeroing-certain-globals
* http://www.nongnu.org/avr-libc/user-manual/mem_sections.html
Second link point out that it is possible to tell the linker explicitly where to place the .noinit section with some commands, maybe that's missing.
Are all the memory sections listed on the map file?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Nope, still not working. Can it be caused by some compiler or linker flag that I use?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I found the problem. I disabled bootloadable from schematic and it seems to work but it doesn't reset the variable if device is coming from power down. Is this an expected behavior?
Also I need my project to be bootloadable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your .noinit area is never initialized. The trick is to put a "magic number" into .noinit to see if the data is valid and / or check the reset cause (look into System Reference Guide) for a software reset.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When I disabled bootloader from the project it was working. I didn't want to deal with sharing a variable between bootloader and bootloadable application on RAM. So, I decided to use internal EEPROM.