PIC16F877 & Serial Comms


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1
    G4LCH's Avatar
    G4LCH Guest

    Angry PIC16F877 & Serial Comms

    Hi Guys,
    I am using a 4MHZ 877 with Debug and Serout And Serout2
    I have in the latter cases added the mode include to get the correct modes
    and ensured that the fuses are set correctly.

    A simple routine returns rubbish in the terminal just as debug does

    nCounter Var Byte

    For nCounter = 1 to 10000
    SerOut PORTC.6,N2400,["Hello"]
    Pause 3000
    Next

    I have added the required declare statements as well

    Define osc 4 ' We have a 4MHz Clock here

    @ DEVICE pic16F877,XT_OSC
    @ DEVICE pic16F877,WDT_OFF
    @ DEVICE pic16F877,PWRT_ON
    @ DEVICE pic16F877,LVP_OFF
    @ DEVICE pic16F877,CPD_OFF
    @ DEVICE pic16F877,PROTECT_OFF

    and used @ DEVICE pic16F877,WDT_ON


    DEFINE DEBUG_REG PORTC
    Define DEBUG_BIT 6
    Define DEBUG_PACING 3000
    DEFINE DEBUG_BAUD 2400
    Define DEBUG_MODE 0

    And altered to inverted in the right state when not using Max232CPE Interface
    that does have the correct voltages with 1uf caps on the charge pump pins.

    and it still gives Garbage a loop back test works fine on both my PC and the Macintosh so I know that my cable is correct.

    is there anything else I should be doing as Visual Basic is reporting framing errors, I adjust the Parity, Stop and data bits to no avail.

    A loopback either side of the MAX232 Interface works fine as well so I know that using this test and the scope that the voltages are correct, I have also tested (visual) with my break out box and the signalling is fine.

    Do I need any pull-up resistors on the ports ?? nope it still works the same way, I have also sent hex out and viewed the stream in hex mode and its garbage.


    any ideas guys ??






    This is driving me nuts

  2. #2
    G4LCH's Avatar
    G4LCH Guest

    Red face Debug

    The debug statement also gives garbage
    Mark

  3. #3
    Join Date
    Aug 2005
    Posts
    42

    Default

    With Serout you need to include this at the top of your code:

    Include "modedefs.bas"

    N2400 will invert the bits so you can just use a resistor straight onto the serial port.

    If you have a max232 then this inverts each bit and you want to send it in True T2400

    Regards

    Sean.
    Last edited by sean-h; - 10th February 2006 at 19:49.
    *********************
    http://www.cncdudez.co.uk
    *********************

  4. #4
    G4LCH's Avatar
    G4LCH Guest

    Smile Thanks Sean

    Sean As I said in my note I have the modedefs in there and it compiles 100%
    I have also tried it direct with 1k resistors and via an interface and i get garbage in all cases.

    Mark

  5. #5
    G4LCH's Avatar
    G4LCH Guest

    Unhappy Update

    With the debug command I have also tried to use 4800 Bps and both inverted and non inverted with no luck still garbage.
    Mark

  6. #6
    Join Date
    Aug 2005
    Posts
    42

    Default

    Mark you say you are using VB.

    Have you simply ran up hyperterminal, set the com port to 2400 8 n 1, hit retunr to open port and then looked for the data, this will illiminate another step if the data is clear and then it has to be the VB side of things.

    Regards

    Sean.
    *********************
    http://www.cncdudez.co.uk
    *********************

Similar Threads

  1. Serial Comms through TX/RX pair jumbled
    By altech6983 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 28th July 2009, 21:04
  2. Some comments on serial comms please.
    By muddy0409 in forum Schematics
    Replies: 1
    Last Post: - 15th June 2007, 09:53
  3. Replies: 8
    Last Post: - 17th January 2007, 19:18
  4. Serial Comms with PIC micros
    By carlsnilsson in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 21st September 2006, 01:00
  5. Replies: 2
    Last Post: - 23rd July 2006, 08:16

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

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