| Example: |
.ORG 0x1000
CSZ_AnalogIn = 0x3B4F ; FLASH address of the descriptor string
RealAndVirtualAIn:
ADIW R26, 0 ; If there was no command tail, we're done
BREQ AEarly_Exit
MOVW R24, R26 ; Set the pointer to the string and attempt
CALL AParseValue ; to parse the numeric value in it
SBRS R21, BIT_PV_VALID ; A value was parsed if the bit is set
Early_Exit:
RET
MOV R24, R22 ; Transfer the LSWord of the value parsed
CALL AGetAtoDValue ; to R25:R24; get that Analog Input value
MOVW R26, R24 ; Preserve the value during the next RCALL
MOVW R22, R24 ; Set the value to be printed in R25:R24
LDI R19, '=' ; Select " = " rather than a " " separator
LDI R25, CSZ_AnalogIn >> 8 ; Print "Analog input" then " = " then
LDI R24, CSZ_AnalogIn & 0xFF ; the HEX WORD value in R23:R22
CALL APrintDescAndHexWORD
MOVW R24, R26 ; Reload R25:R24 with the value printed
JMP APrintEqualDecWORD ; in HEX and print it in decimal as well
|
| Test it: |
m>@ 4096 0
Analog input = 0x001A = 26
m>@ 4096 1
Analog input = 0x0000 = 0
m>@ 4096 2
Analog input = 0x0000 = 0
m>@ 4096 5 ; The LED configured as "heartbeat", when ON
Analog input = 0x03EC = 1,004
m>@ 4096 5 ; same LED, when OFF a moment later
Analog input = 0x0000 = 0
m>@ 4096 8
Analog input = 0x00E0 = 224
m>V
SRAM contents:
0280: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0290: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
02A0: 54 04 00 00 00 00 00 00-00 00 00 00 00 00 00 00 T...............
02B0: 5E 04 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ^...............
m>@ 4096 32
Analog input = 0x0454 = 1,108
m>@ 4096 48
Analog input = 0x045E = 1,118
m>
|
Dropin: (setup code) |
; Setup for the PrintEqualDecWORD() call:
; Passed: R25:R24 WORD wValue the WORD value to print after the " = " string
; Returns: Nothing.
; Alters: R18, R20, R22 through R27, the FLAGs, and the COM1 Transmit Buffer
; Notes: Suppress any leading zeros, but print comma if 1,000 or greater
|