Syntax:
Poke(location, value)
Command Availability:
Available on all microcontrollers.
Explanation:
The Poke command writes information to the on-chip RAM of the microcontroller.
location is a word variable that gives the address to write. The exact range of valid values varies from chip to chip.
value is the data to write to the location.
This command should not normally be used, since it makes porting code to another chip very difficult — register and RAM addresses are chip-specific.
Example 1:
'This program will set all of the PORTB pins high
POKE (6, 255) ' <<< the Poke instructionKey line: POKE (6, 255) — writes the raw value 255 directly to RAM/register address 6, setting every bit in that byte, on a chip where that address
corresponds to PORTB.
Example 2:
;Chip Settings
#chip 16F88
Dir PORTB out
Do Forever
FlashPin @PORTB, 8
Wait 1 s
Loop
Sub FlashPin (In DestVar As word, In DestBit)
Poke DestVar, Peek(DestVar) Or DestBit ' <<< the Poke instruction, setting a bit
Wait 1 s
Poke DestVar, Peek(DestVar) And Not DestBit
End SubKey line: Poke DestVar, Peek(DestVar) Or DestBit — reads the port’s current value with Peek, sets the requested bit with Or, and writes the result back with Poke, turning that pin on without disturbing the others; the next line clears it again with And Not.
Using @ before the name of a variable (including a special function register) gives you the address of that variable, which can then
be stored in a word variable and used by Peek and Poke to indirectly access the location.
See Also:
- Peek — reading the location this page writes

