* (ARM peripheral and memory access)

equivalent of PEEK and POKE


* variable

* constant               '  for array of constants, string or bytes

* ( expression)          ' added in version 8.04 of the compiler


The C pointer syntax is used to give direct access to the ARM peripheral registers and memory.

x = *addr      '  equivalent of PEEK(addr) for a word

*addr = x      '  equivalent of POKE(addr,x) writes x as a word into address addr

This gives the programmer the ability to directly control the ARM hardware.  Details on what the registers do can be found in the NXP User Manuals for the corresponding chip (LPC2103 for ARMmite, ARMexpress LITE, PRO,  LPC2106 for ARMexpress,  LPC2138 for ARMweb, and  LPC1751/6 for the PROplus and SuperPRO)

Examples of programming the registers can be found in the BASIClib directory which contains sub-programs that control various hardware functions.

If you prefer the PEEK or POKE versions you can always use the pre-processor

#define PEEK(addr)   (*(addr))       ' the () ensure only addr is used in the address calculation
#define POKE(addr,value)   *(addr) = value

Pointers only operate on 32 bit WORD values, and should use WORD or 4-byte alligned addresses.

For byte and halfword access see RD_BYTE , WR_BYTE , RD_HALF and WR_HALF


' from the HWPWM.bas  library

'* ---- Timer 2 --------------------------------------------
#define T2_TCR         * &HE0070004
#define T2_TC           * &HE0070008
#define T2_PR           * &HE007000C
#define T2_MCR        * &HE0070014
#define T2_MR0         * &HE0070018
#define T2_MR1         * &HE007001C
#define T2_MR2         * &HE0070020
#define T2_MR3         * &HE0070024

 T2_PR  = prescale
 T2_TCR = TxTCR_COUNTER_ENABLE            ' Timer1 Enable
 T2_MR3 = cycletime -1
 T2_MCR = &H400    ' rollover when count reaches MR3

Differences from other BASICs

See also