data logger/nvram

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
ljfischer
Posts: 19
Joined: Sat Jan 04, 2014 5:03 am

data logger/nvram

Post by ljfischer »

I know this topic must have come up, but I don't find anything obvious in the forum. Im using an stm32f407 - the cheapie board. I would like to write events to NVRAM.
- Does chibios have support for writing to flash/nvram that is native to this board?
Just point me to the appropriate thread that I know must exist...

Thanks,
Larry
ljfischer
Posts: 19
Joined: Sat Jan 04, 2014 5:03 am

Re: data logger/nvram

Post by ljfischer »

So, Ive ordered an SD Card xface, and will use that when it arrives. Im still curious about the onboard Flash though...
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: data logger/nvram

Post by Giovanni »

Hi,

There is an option to enable the NVRAM but handling is up to the application.

Giovanni
User avatar
alex31
Posts: 445
Joined: Fri May 25, 2012 10:23 am
Has thanked: 57 times
Been thanked: 88 times

Re: data logger/nvram

Post by alex31 »

what do you call nvram, the 4Kb backup ram ?

seems short in room for logging purpose no ?

Alexandre
User avatar
Vic20
Posts: 15
Joined: Fri Apr 25, 2014 7:45 pm

Re: data logger/nvram

Post by Vic20 »

If you talk about the 4kB backup RAM it is quite easy to access, you don't need ChibiOS for that.
It's all in the Reference Manual (RM0090). You should have a copy if you want to do any serious work on the MCU.

The range of this memory is 0x4002 4000 - 0x4002 4FFF and you can access it using pointers, por instance.

To be able to acess to this memory you need to activate the access to it using as is described in the section 4 of the reference manual.

● Access to the backup SRAM
1. Enable the power interface clock by setting the PWREN bits in the RCC APB1
peripheral clock enable register (RCC_APB1ENR)
2. Set the DBP bit in the PWR power control register (PWR_CR) to enable access to the
backup domain
3. Enable the backup SRAM clock by setting BKPSRAMEN bit in the RCC APB1
peripheral clock enable register (RCC_APB1ENR)

After that you just need to directly write to the backup RAM region.

The logs can also be written to the last sectors of the flash memory.
Unfortunatelly the last sectors are quite big (128kB each) so, al least, you would need to reserve
128kB to logging.

The procedures to access the flash are also in the reference manual.

Best regards
Vicente
Post Reply