Serin with 16F876


+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2012
    Posts
    47

    Default Serin with 16F876

    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:

    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
    Where do I go wrong?
    (Just to check, I tried 'normal' and 'inverted' mode.)

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    1,813

    Default Re: Serin with 16F876

    its all guesswork with no config word setting offered;

    it's more than likely the osc won't function reliably @20mhz with the default pbp xt osc config

    can you even flash a led ?
    This is more entertaining than Free to Air TV

  3. #3
    Join Date
    Feb 2012
    Posts
    47

    Default Re: Serin with 16F876

    No idea what was wrong, but now it works.
    (It may have been the FTDI USB to serial cable.)

Similar Threads

  1. hserin and 16f876
    By novino in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 20th October 2009, 13:13
  2. 16F876 ADC problem
    By Douwe in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 8th June 2006, 20:38
  3. Blink Programme for 16F876
    By banjaxxed in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 13th April 2006, 01:03
  4. Adcin on a 16F876
    By krapoto in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 10th April 2006, 22:15
  5. Confusion and possible bug on 16f876
    By khufumen in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 21st May 2005, 03:59

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts