Register access

Questions about the BASICtools and MakeItC
Post Reply
YahooArchive
Posts: 1462
Joined: Fri Oct 19, 2012 5:11 am

Register access

Post by YahooArchive »

>from the help line
>*0xE005C008 =&H73 (for example), or I = *0xE005C008

>Where *0xE005C008 (I2C1DAT) is an 8 bit register. It is on a 4 byte
boundary...

>I know a$(1) = &H12345678 simply takes the LSB, but of course a$ has been
declared as an array of bytes.

>I'm getting a data problem, but don't know if this is it? If so is there a
work around?

all LPC registers are on 32 bit boundaries, and support word writes. All BASIC
access to them is as a word. There's no way to access a byte of a register, and
there really should not need to be. If you want to retain bits do an operation
like

*REG = (*REG and (mask-expression like &HFFFF00FF)) or (expression)

a$(1) = &H12345678 would be an error, and the compiler would truncate the result
to a byte value

You will get data aborts if you try to access a register on a non-word alligned
address.



YahooArchive
Posts: 1462
Joined: Fri Oct 19, 2012 5:11 am

Re: Register access

Post by YahooArchive »

> Almost all - the Fast IO regs allow byte access
>
> FIO0DIR0 8 (byte) 0x3FFFC000
> FIO0DIR1 8 (byte) 0x3FFFC001
> FIO0DIR2 8 (byte) 0x3FFFC002
> FIO0DIR3 8 (byte) 0x3FFFC003

these are just definitions of byte addresses for the 32 bit FIO0DIR register,
the FIO0DIR you can access in BASIC

there is currently no way to do an individual byte access to these other than

FIO0DIR = (FIO0DIR and &HFF00FFFF) or (x << 16) ' same as FIO0DIR2

YahooArchive
Posts: 1462
Joined: Fri Oct 19, 2012 5:11 am

Re: Register access

Post by YahooArchive »

Just to clarify: When you say 'no way' you mean 'no way in BASIC' don't you? You
can certainly access individual bytes on non-word aligned addresses on the
LPC2103 (and other ARM V6 architecture devices) in Oberon-07 so I assume you can
in C as well.

--
Chris Burrows
CFB Software
Armaide: LPC2xxx Oberon-07 Development System
http://www.armaide.com

Post Reply