If a number can be represented as a31-bit signed number, then no memory allocation is required. However, if the number doesn't fit, then a memory allocation is required to allocate a large int.
This failure could be happening with either the address or the value. It looks like none of the PWR registers use any of the upper bits so you should be ok on that front.
It looks like stm.PWR has the value 1073770496 (0x40007000). The largest positive value that can be stored in a 31-bit signed number is 0x3FFFFFFF which is what's probably causing the problem.
You should be able to do something like add:
Code: Select all
PWR_CSR = cosnt(stm.PWR + stm.PWR_CSR)
outside your function (the const bit is optional) and then use
inside your function to move the memory allocation to where the declaration occurs rather than inside your function.