mesamune80
New Member
Hi all,
Any of you come a cross this 74LS165 with PIC,i am having a problem reading the bit send by this IC to my microcontroller..please comment about my code thanks.This is my code in PIC Simulator IDE (Basic format).
TRISB = %10000110
TRISC = 0
PORTB = 6
Dim b7 As Bit
Dim b6 As Bit
Dim b5 As Bit
Dim b4 As Bit
Dim b3 As Bit
Dim b2 As Bit
Dim b1 As Bit
Dim b0 As Bit
Low PORTB.1 'set clock low
High PORTB.4 'bring clock inhibit high
High PORTB.3 'bring shift/load high
start:
Gosub serial_in
If b7 = 1 Or b0 = 1 Then
Low PORTC.7
Low PORTC.6
Low PORTC.5
Low PORTC.4
Low PORTC.3
Low PORTC.2
Low PORTC.1
Low PORTC.0
Else
If b7 = 0 Or b0 = 0 Then
High PORTC.7
High PORTC.6
High PORTC.5
High PORTC.4
High PORTC.3
High PORTC.2
High PORTC.1
High PORTC.0
Endif
Endif
Goto start
End
serial_in:
High PORTB.3 'bring shift/load down momentarily
WaitUs 10
Low PORTB.3
WaitUs 10
Low PORTB.4 'bring clock inhibit low
b7 = PORTB.2 'load bit into B2
High PORTB.1 'Bring clock pin high then low
WaitUs 10
Low PORTB.1
WaitUs 10
b6 = PORTB.2 'load bit into B2
High PORTB.1 'Bring clock pin high then low
WaitUs 10
Low PORTB.1
WaitUs 10
b5 = PORTB.2 'load bit into B2
High PORTB.1 'Bring clock pin high then low
WaitUs 10
Low PORTB.1
WaitUs 10
b4 = PORTB.2 'load bit into B2
High PORTB.1 'Bring clock pin high then low
WaitUs 10
Low PORTB.1
WaitUs 10
b3 = PORTB.2 'load bit into B2
High PORTB.1 'Bring clock pin high then low
WaitUs 10
Low PORTB.1
WaitUs 10
b2 = PORTB.0 'load bit into B0
High PORTB.1 'Bring clock pin high then low
WaitUs 10
Low PORTB.1
WaitUs 10
b1 = PORTB.2 'load bit into B2
High PORTB.1 'Bring clock pin high then low
WaitUs 10
Low PORTB.1
WaitUs 10
b0 = PORTB.2 'load bit into B2
High PORTB.1 'Bring clock pin high then low
WaitUs 10
Low PORTB.1
WaitUs 10
Return
Any of you come a cross this 74LS165 with PIC,i am having a problem reading the bit send by this IC to my microcontroller..please comment about my code thanks.This is my code in PIC Simulator IDE (Basic format).
TRISB = %10000110
TRISC = 0
PORTB = 6
Dim b7 As Bit
Dim b6 As Bit
Dim b5 As Bit
Dim b4 As Bit
Dim b3 As Bit
Dim b2 As Bit
Dim b1 As Bit
Dim b0 As Bit
Low PORTB.1 'set clock low
High PORTB.4 'bring clock inhibit high
High PORTB.3 'bring shift/load high
start:
Gosub serial_in
If b7 = 1 Or b0 = 1 Then
Low PORTC.7
Low PORTC.6
Low PORTC.5
Low PORTC.4
Low PORTC.3
Low PORTC.2
Low PORTC.1
Low PORTC.0
Else
If b7 = 0 Or b0 = 0 Then
High PORTC.7
High PORTC.6
High PORTC.5
High PORTC.4
High PORTC.3
High PORTC.2
High PORTC.1
High PORTC.0
Endif
Endif
Goto start
End
serial_in:
High PORTB.3 'bring shift/load down momentarily
WaitUs 10
Low PORTB.3
WaitUs 10
Low PORTB.4 'bring clock inhibit low
b7 = PORTB.2 'load bit into B2
High PORTB.1 'Bring clock pin high then low
WaitUs 10
Low PORTB.1
WaitUs 10
b6 = PORTB.2 'load bit into B2
High PORTB.1 'Bring clock pin high then low
WaitUs 10
Low PORTB.1
WaitUs 10
b5 = PORTB.2 'load bit into B2
High PORTB.1 'Bring clock pin high then low
WaitUs 10
Low PORTB.1
WaitUs 10
b4 = PORTB.2 'load bit into B2
High PORTB.1 'Bring clock pin high then low
WaitUs 10
Low PORTB.1
WaitUs 10
b3 = PORTB.2 'load bit into B2
High PORTB.1 'Bring clock pin high then low
WaitUs 10
Low PORTB.1
WaitUs 10
b2 = PORTB.0 'load bit into B0
High PORTB.1 'Bring clock pin high then low
WaitUs 10
Low PORTB.1
WaitUs 10
b1 = PORTB.2 'load bit into B2
High PORTB.1 'Bring clock pin high then low
WaitUs 10
Low PORTB.1
WaitUs 10
b0 = PORTB.2 'load bit into B2
High PORTB.1 'Bring clock pin high then low
WaitUs 10
Low PORTB.1
WaitUs 10
Return