SETREG
(Created page with "= <span style="font-size: 14pt; font-weight: bold;">Action</span> = Writes a byte value to an internal register. <span style="font-family: Arial;"> </span> <span style...") |
|||
Line 78: | Line 78: | ||
<span style="font-family: Arial;"> </span> | <span style="font-family: Arial;"> </span> | ||
− | <span style="font-family: Arial;"> </span> | + | <span style="font-family: Arial;"> </span>[[File:Notice.jpg|notice]]In version 2078, all internal registers (R0-R31) are made available as normal BYTE variables. This means that you can simply assign or read a register from basic : Rx=value. |
+ | |||
+ | This is more convenient than using SETREG and GETREG. | ||
= <span class="f_Header">See also</span> = | = <span class="f_Header">See also</span> = |
Latest revision as of 21:25, 17 January 2017
Contents |
Action
Writes a byte value to an internal register.
Syntax
SETREG Reg , value
Remarks
Most AVR chips have 32 registers named R0-R31. Registers R16-R31 can be assigned directly. Register R0-R15 do not accept this.
In some cases you might want to write to the internal registers. While you can include some ASM code directly, you can also use the BASIC SETREG statment.
Reg |
The register name : R0-R31 or a register definition. |
Value |
A constant or byte value to assign to the register. |
PEEK and POKE work with an address. And will return a HW register on the Xmega since Xmega has a different address map.
GetReg and SetReg will read/write registers on all AVR processors.
Internally the compiler will use R24 if you write a constant to register R0-R15 :
For example :
Setreg R0 , 1
Compiles into:
Ldi R24,$01
Mov R0, R24
Setreg R31 , 1
Compiles into:
Ldi R31,$01
In version 2078, all internal registers (R0-R31) are made available as normal BYTE variables. This means that you can simply assign or read a register from basic : Rx=value.
This is more convenient than using SETREG and GETREG.
See also
Example
Languages | English • Deutsch |
---|