Serial data sent to 16F627A being read incorrectly by PIC?


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default Re: Serial data sent to 16F627A being read incorrectly by PIC?

    Take the PC out of the loop you're just introducing more variables, your LA is all you need.

    A couple of things to check, is the Fosc (the clock running the PIC, not necesarily the crystal) you tell the compiler is the same as the actual? Is the signal inverted?

    Use your LA to decode the signals and look at the polarity? Let the LA determine the baud rate or calculate the bit time at 2400 and measure it on the LA.
    George

  2. #2
    Join Date
    Jun 2005
    Posts
    53


    Did you find this post helpful? Yes | No

    Default Re: Serial data sent to 16F627A being read incorrectly by PIC?

    I should have elaborated more on the PC part; I moved to sending bytes via PC as a direct result of this issue. The PIC in question is actually supposed to be talking to another device via serial - I need to send a byte to this device to query it and then it responds with a few bytes I need to capture. I can successfully send the byte to the device and the PIC captures the correct amount of bytes in return but it just captures the "wrong" bytes. I changed my code on the PIC to look for these "wrong" bytes and it actually functions but this is quite a hack and I'd like to sort out why it's not reading them properly in the first place.

    I put together the simple code above and connected to the FTDI on my computer to be able to quickly test the result of sending various bytes to the PIC to see their result. The bytes my PC send are interpreted by the PIC the same as the bytes the other device was sending (e.g. device/PC sends 0x0A [confirmed w/ LA] but PIC sees 0x3D)

    The RX signal is not inverted. The device is listening for an inverted signal to start but that's on the TX side which is passed through an inverter. The TX from the PIC is successfully received by the device and the device's response (not inverted) does not function.

    Confirming the baud with the logic analyzer is a good idea; I'll have to do that and report the value. I believe I did have it set to "autobaud" when I first tested and it was something like 2389 or slightly off from 2400 baud but I will confirm again to be sure.

  3. #3
    Join Date
    May 2013
    Location
    australia
    Posts
    2,645


    Did you find this post helpful? Yes | No

    Default Re: Serial data sent to 16F627A being read incorrectly by PIC?

    just tried your code on a 16f648a , works perfectly from my pc usb through tty converter to pic , you must have polarity of signal screwed up.
    Attached Images Attached Images  
    Warning I'm not a teacher

  4. #4


    Did you find this post helpful? Yes | No

    Default Re: Serial data sent to 16F627A being read incorrectly by PIC?

    The difference between 2389 and 2400 would not seem a big deal, it only 0.5% (if my maths right, which is unlikely)
    George

  5. #5
    Join Date
    Jun 2005
    Posts
    53


    Did you find this post helpful? Yes | No

    Default Re: Serial data sent to 16F627A being read incorrectly by PIC?

    I traced out the board and realized another component sitting between the board input and PIC was inverting the signal. The board is being re-purposed from a different use so I was able to bypass that and everything is working as expected. Thanks

Similar Threads

  1. how to buffer serial data on pic?
    By kiteman in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 29th March 2010, 19:07
  2. How to read PIC serial no. from EEPROM with PBP?
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th December 2009, 10:27
  3. Forward Serial Data from pic to pc
    By Muller in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 2nd September 2008, 21:46
  4. How to read Serial number programmed into PIC
    By freddayz in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 22nd April 2008, 02:36
  5. PIC to PIC Serial data using Cat5 cable
    By Andy Wood in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 3rd May 2007, 02:42

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