PDA

View Full Version : hex to bin converter



darkman
- 27th April 2005, 13:57
@ device XT_OSC,PROTECT_OFF,WDT_OFF,PWRT_ON,MCLR_ON,BOD_OFF ,LVP_OFF,PROTECT_OFF,CPD_OFF
TRISB=%00000000
CMCON=7

B0 var byte
B1 var byte

FOR B1=0 to 1
LOOKUP B1, ["$3F $FF"],B0

' ==== B0 hex to bin convert here ====

PAUSE 200
PORTB.0=B0.7
Pulsout PORTB.1,1
PORTB.0=B0.6
Pulsout PORTB.1,1
PORTB.0=B0.5
Pulsout PORTB.1,1
PORTB.0=B0.4
Pulsout PORTB.1,1
PORTB.0=B0.3
Pulsout PORTB.1,1
PORTB.0=B0.2
Pulsout PORTB.1,1
PORTB.0=B0.1
Pulsout PORTB.1,1
PORTB.0=B0.0
Pulsout PORTB.1,1
LOW PORTB.1

NEXT B1


I need hex to bin convert data in my B0
please help :(

Dwayne
- 27th April 2005, 14:41
Hello Darkman,

I don't understand what you want... but maybe using the bitshift command is what you are looking for....

Data var byte;
counter var byte

For counter=0 to 7
PORTB.0=Data.7 'assigns PORTB.0 the Bit Data.7 has (your part of the program).
Pulsout PORTB.1,1 'your part of the program...
Data=Data << 1 'shift left
Next counter

Unfortunately I really do not know what you are trying to accomplish... You assign Portb.0 a bit, but transmit out a pulse on Portb.1 (which is a different Port) Yet you never change the value of this POrtb.1... It is always the same.

Dwayne