This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

UNINIT Section Gets Zero Filled

Hi, 

I'm trying to declare a variable that can survive a watchdog reset. 

I'm using Keil uVision with the MDK-ARM compiler V6.19 with an STM32L0xx microcontroller. 

There's a NoInit section of the RAM set up in the project variant options:

I've set the options on the file that has the variable definition to use the NoInit RAM section:

The scatter file for the project is changed to add a .bbs.NoInit section for IRAM2:

; ***************
; * Scatter-Loading Description File generated by uVision *
; ***************
LR_IROM1 0x08000000 0x00007FF0 { ; load region size_region
    ER_IROM1 0x08000000 0x00007FF0 { ; load address = execution address
        *.o (RESET, +First)
        *(InRoot$$Sections)
        .ANY (+RO)
        .ANY (+XO)
    }
    RW_IRAM1 0x20000000 0x00001FF0 { ; RW data
        .ANY (+RW +ZI)
    }
    RW_IRAM2 0x20001FF0 UNINIT 0x00000010 { ; No init section
        *(.bss.NoInit)
    }
}

And the variable is declared like: 
   uint8_t  infLoopIdentifier __attribute__((section(".bss.NoInit")));

But the variable is always initialised as 0 after the WDG reset.

I've checked the map file and the variable is being put into the NoInit section: 

     infLoopIdentifier                        0x20001ff0   Data           1  lto-llvm-7a9e85.o(.bss.NoInit)

Can anyone help and point out what I'm doing wrong?

Thanks

Stu