Hello,
I have a strange thing going on here...
I try to decode serial information (shift register) to 2 seven-segment displays.
This is the code:The strange thing is that PORTA.2, although configured as input, is changed to an output!Code:DEFINE OSC 8 CMCON = 7 TRISA = %11111100 ' PORTA.0 and PORTA.1 = Outputs (Anodes Displays) TRISB = %00000000 ' PORTB = Outputs (Cathodes Displays) W Var Word ' Variable for ShiftIn PORTB = 255 ' All Cathodes High, display off PORTA.0 = 0 ' Anode Low, display off PORTA.1 = 0 ' Anode Low, display off ' PORTA.2 = Clock in ' PORTA.3 = Data in ' PORTA.4 = Latch in MainLoop: ShiftIn PORTA.3, PORTA.2, 0, [W\16] WaitLoop: ' Wait for the Latch to go High If PORTA.4 = 0 then Waitloop PORTB = (W & 255) XOR 255 ' PORTB = Lowest 8 Bits PORTA.0 = (W >> 8) & 1 ' PORTA.0 = Anode display PORTA.1 = (W >> 8) & 2 ' PORTA.1 = Anode display Goto MainLoop
If a comment the 'ShiftIn' out, PORTA.2 stays an input.
I am sure I am overlooking something, but what????




Bookmarks