Name:
peeksfr
Syntax:

PEEKSFR location,variable,variable,...

Location - is a variable/constant specifying a register address. Valid values are 0 to 255 (not all implemented, see below).

Variable - is a byte variable where the data is returned.

Description:

Read data from the microcontroller special function registers.

This allows experienced users to read the on-board peripheral microcontroller settings. This command is for M2 and X2 parts only, for other parts see the peek command. The peeksfr command is for experienced users to study the internal microcontroller SFR (special function registers).

Only SFRs associated with peripherals (e.g. ADC or timers) may be accessed. Peeking or poking SFRs associated with PICAXE program operation (e.g. FSR, EEPROM or TABLE registers) will cause the PICAXE chip to immediately reset.

 

X2 parts

As location can only take the value 0-255 on X2 locations taken from the Microchip datasheet drop the initial 'F' from the hexadecimal value

e.g. BAUDCON FB8h becomes $B8

 

M2 parts

As location can only take the value 0-255 the value for M2 locations taken from the Microchip datasheet are created as follows:

Bit 7-5 Memory Bank $00-$07
Bit 4-0 Addresses $0C to $1F on this bank
    ($00-$0B are invalid and cause instant reset)

  e.g. BAUDCON, address 01Fh on bank 3, becomes %011 11111

Applies To:
08M2, 14M2, 18M2, 20M2, 20X2, 28X2, 40X2
See Also:
Related Create:
    Share:
    Print:

    Retrieving values from SFR

    This program demonstrates retrieving the value currently set in the 'OSCTUNE' SFR and placing that value in variable 'b1'.

    Code Example:
    	peeksfr $9B,b1	; Read OSCTUNE into variable b1
    Copy Code Submit an Example

    Submit Your Own Code!

    You must be logged in to submit code examples. Login now.