PDA

View Full Version : Bin As Variable



Eyal
- 30th September 2005, 16:35
if someone know if it possible to use with variable in bin command
SEROUT2.........BIN16 VOLT
I NEED
SEROUT2.........BINx VOLT

Eyal

Darrel Taylor
- 30th September 2005, 17:33
Hi Eyal,

Can't do it the easy way, but this should do the trick.
; ----[Send X number of binary digits]----------
ASM
SER_BINx macro Port, Pin, Mode, Value, X
SEROUT2DPIN?T Port, Pin
SEROUT2MODE?C Mode
SEROUT2PACE?C 000h
SEROUT2COUNT?B X
SEROUT2NUM?W Value
SEROUT2BIN?
endm
ENDASM

; ----[Force PBP to include the macro's]---(doesn't use any code space)-----
@ ifdef AddSEROUTcode
SEROUT2 PORTB.0,396,[BIN16 R0, REP " "\R0.lowbyte]
@ endif
; ----------------------------------------------

SOpin VAR PORTB.0
Volt VAR WORD
BINcount VAR BYTE

Volt = 115

FOR BINcount = 16 to 1 step -1
@ SER_BINx _SOpin, 396, _Volt, _BINcount
SEROUT2 SOpin, 396,[13,10]
NEXT BINcount; should send
0000000001110011
000000001110011
00000001110011
0000001110011
000001110011
00001110011
0001110011
001110011
01110011
1110011
110011
10011
0011
011
11
1