EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

[lpc23xx] How to use Battery-RAM?

Started by Jakub Szumacher March 31, 2009
Hello.

How to use battery Ram in LPC23xx?

How to define and use a simple Array in battery Ram (any example in Crossworks)?

pozdr
Kuba


An Engineer's Guide to the LPC2100 Series

> How to use battery Ram in LPC23xx?
>
> How to define and use a simple Array in battery Ram (any example in
> Crossworks)?

Battery-backed ram is special--it can only be accessed as 16-bit words,
IIRC. You need to read the LPC2k user manual.

--
Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk
CrossWorks for ARM, MSP430, AVR, MAXQ, and now Cortex-M3 processors

----Original Message----
From: l...
[mailto:l...] On Behalf Of Jakub
Szumacher Sent: 20 November 2008 18:48 To:
l... Subject: [lpc2000] [lpc23xx] How to
use Battery-RAM?

> Hello.
>
> How to use battery Ram in LPC23xx?
>
> How to define and use a simple Array in battery Ram (any
> example in Crossworks)?
>

You have to define a named area of memory...
The battery ram location and size should be defined in the
LPCxxx_MemoryMap.xml file
E.g. in LPC2478 it is at 0xE0084000

Then in flash_placement.xml you need to name the memory area:




Then you position your variables in the battery ram like this:

unsigned int NVRamInt __attribute__ ((section(".nvrdata")));

--
Tim Mitchell


It can only by accessed as 32-bit words actually.

Regards,


Ivan Amancio


_____

De: Paul Curtis [mailto:p...@rowley.co.uk]
Enviada em: ter-feira, 31 de mar de 2009 12:42
Para: l...
Assunto: RE: [lpc2000] [lpc23xx] How to use Battery-RAM?

> How to use battery Ram in LPC23xx?
>
> How to define and use a simple Array in battery Ram (any example in
> Crossworks)?

Battery-backed ram is special--it can only be accessed as 16-bit words,
IIRC. You need to read the LPC2k user manual.

--
Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk
CrossWorks for ARM, MSP430, AVR, MAXQ, and now Cortex-M3 processors

--------

AVISO LEGAL
Esta mensagem eh exclusivamente para a pessoa do destinatario, podendo conter infomacoes confidencias ou legalmente protegidas. A transmissao incorreta da mensagem nao acarreta a perda de sua confidencialidade. Caso esta mensagem tenha sido recebida por engano, solicitamos que seja devolvida ao rementente e apagada de seu sistema imediatamente. Eh vedado a qualquer pessoa que nao seja destinatario usar, revelar, distribuir ou copiar qualquer parte desta mensagem.

DISCLAIMER
This message is destined exclusively to the intendend receiver. It may contain confidential or legally protected information. The incorrect transmission of this message does not mean the loss of its confidentiality. If this message is receiveid by mistake, please send it back to the sender and delete it from your system immediately. It is forbidden to any person who is not intendend receiver to use, reveal, distribute, or copy any part if this message.

www.topdata.com.br



NVRAM is much like any other type of RAM except that all accesses are in 32-bit words. So, when reading from it, or if you're dealing with elements exactly 32-bits long (e.g., ints, pointers), then there are no problems, just allocate the variable so it lands in NVRAM.

When writing values other than those that are 32-bits long (e.g., char array), you need to either pre-pack the data into a 32-bit word then write it, or perform a read-modify-write algorithm. Can't give you the code for Crossworks, but for IAR, first define the memory for NVRAM. Then define your variable;

__no_init unsigned long NVRAM_hostname[HOSTNameLength] @ "NVRAM";

Then build a write-byte function with which you can then write some string-copy routines to use it to modify NVRAM:

void NVRAM_writebyte(unsigned long address, unsigned char data) {
unsigned long oldData;
unsigned long mask;
unsigned long newData;
int shift;
int byte;

// create our shift value - remember this is little endian
byte = (address & 0x03);
shift = (byte << 3);
// word-align our address and ensure it's in NVRAM space
address = (address & 0x000007FC) | 0xE0084000;
// put the new data where it should be in the word
newData = (unsigned long)data << shift;
// create mask pattern to erase the bits we don't want from the read
mask = 0xFF << shift;

// read whole word from NVRAM
oldData = *(unsigned long*)(address);
// mask out the bits we DON'T want
oldData &= ~mask;
// or in the new bits we DO want
oldData |= newData;
// write word to NVRAM
*(unsigned long*)(address) = oldData;
}
-----Original Message-----
From: l... [mailto:l...] On Behalf Of Jakub Szumacher
Sent: Thursday, November 20, 2008 11:48 AM
To: l...
Subject: [lpc2000] [lpc23xx] How to use Battery-RAM?

Hello.

How to use battery Ram in LPC23xx?

How to define and use a simple Array in battery Ram (any example in Crossworks)?

pozdr
Kuba



No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.5.287 / Virus Database: 270.12.4/2077 - Release Date: 04/24/09 07:54:00


The 2024 Embedded Online Conference