I am trying to read the serial (RS232) input on LEDs, connected to PORTB of the 16F876.
(Later this will be part of a larger application, I need both PORTB and PORTC as outputs.)
I am using an FTDI USB cable for the serial input.
I can see on an oscilloscope that serial information is indeed generated, but no display on the LEDs.
Probably I am overlooking something obvious(!), but I even can't get this simple test setup working.
I am sending 8 bits, no parity, 9600 Baud.
This is the code I am testing:
Where do I go wrong?Code:'* * * * * * * * * * * * * * * * * * * * * * * * '* PORTA.0 = Serial input '* PORTB = Outputs to LEDs + 1 K.ohm resitors '* /MCRL to +5 V through 4.7 K.ohm resistor '* Oscillator 20 MHz. '* 16F876 '* * * * * * * * * * * * * * * * * * * * * * * * TRISA= %00000001 ' PORTA.0 = Input TRISB= %00000000 ' PORTB = Outputs ADCON1=7 ' Digital mode DEFINE OSC 20 ' 20 MHZ OSC. Value var byte ' Value from port PORTB = 0 ' Start with all LEDs off again: Serin PORTA.0, 6, Value ' 9600 Baud, inverted ' Serin PORTA.0, 2, Value ' 9600 Baud, normal PORTB = Value goto again
(Just to check, I tried 'normal' and 'inverted' mode.)




Bookmarks