'12 bit Parallel to Serial by Derek Hodge
'11 Oct 2013
'Device 18-pin 16F627A
'Inputs RA0 - RA7 , RB4, RB5, RB6, RB7
'serial out TX Pin 8
Define CONFIG = 0x3f18
Define CLOCK_FREQUENCY = 4
AllDigital
Hseropen 4800
TRISA = 0xff 'Set Port A as input. Have also tried this using CONFIGPIN but same result
TRISB = 0xf0 'Set most significant 4 bits of PORT B as input
Dim ls8 As Byte 'LS 8 bits
Dim ms4 As Byte 'MS 4 bits
loop:
PORTA = ls8
PORTB = ms4
Low ms4.0 'Make sure LS bits are 0
Low ms4.1
Low ms4.2
Low ms4.3
ms4 = ShiftRight(ms4, 4) 'Move the data bits from most significant positions to LS positions
Hserout ls8, ","
Hserout ms4, CrLf
WaitMs 500
Goto loop