SERIN2 Receiving Wrong Data


+ Reply to Thread
Results 1 to 26 of 26

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,821


    Did you find this post helpful? Yes | No

    Default Re: SERIN2 Receiving Wrong Data

    What is the clock of each PIC you use?

    Ioannis

  2. #2
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    654


    Did you find this post helpful? Yes | No

    Default Re: SERIN2 Receiving Wrong Data

    Quote Originally Posted by Ioannis View Post
    What is the clock of each PIC you use?

    Ioannis
    The sending device has the typical 18F4550 USB setup and it is set to "Define OSC 48". The receiving device is set to "DEFINE OSC 16".
    "No one is completely worthless. They can always serve as a bad example."

    Anonymous

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,821


    Did you find this post helpful? Yes | No

    Default Re: SERIN2 Receiving Wrong Data

    I guess then, the sending device is interrupted by the USB routines while sending and as a consequence the transmission of RS-232 at that time is corrupted.

    Ioannis

  4. #4
    Join Date
    Aug 2011
    Posts
    414


    Did you find this post helpful? Yes | No

    Default Re: SERIN2 Receiving Wrong Data

    If you're using interrupts on either end then you shouldn't use SEROUT/SERIN as interrupts will upset the timing.
    You should use the hardware HSEROUT/HSERIN routines, but then you will have to use the dedicated UART IO pins.

    Also, you would be better off running the receiving end with a faster osc setting... try 32MHz instead of 16.

  5. #5
    Join Date
    May 2013
    Location
    australia
    Posts
    2,392


    Did you find this post helpful? Yes | No

    Default Re: SERIN2 Receiving Wrong Data

    I guess then, the sending device is interrupted by the USB routines while sending and as a consequence the transmission of RS-232 at that time is corrupted.
    that can't be right because

    I know device A is sending the right data because I can see it with a logical analyzer.
    my next guess is that device A is running on 3Volts
    this guessing game has got longer legs than i expected
    Warning I'm not a teacher

  6. #6
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,821


    Did you find this post helpful? Yes | No

    Default Re: SERIN2 Receiving Wrong Data

    Quote Originally Posted by richard View Post
    that can't be right because

    my next guess is that device A is running on 3Volts
    this guessing game has got longer legs than i expected
    I think it can be right since Serout/Serout2 happens in a async rate. USB is fast but in any case the soft Serial is interrupted randomly.

    The logic analyzer catches one instant of this.

    Lowering the baud rate helped because of that interrupt thing. Lower baud has more time on every bit and the fast USB gets away.

    I have long that I abandoned software serial port use because of such matters.

    Ioannis
    Last edited by Ioannis; - 29th April 2024 at 19:50.

  7. #7
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    654


    Did you find this post helpful? Yes | No

    Default Re: SERIN2 Receiving Wrong Data

    Quote Originally Posted by tumbleweed View Post
    If you're using interrupts on either end then you shouldn't use SEROUT/SERIN as interrupts will upset the timing.
    You should use the hardware HSEROUT/HSERIN routines, but then you will have to use the dedicated UART IO pins.

    Also, you would be better off running the receiving end with a faster osc setting... try 32MHz instead of 16.
    The PIC ports with HSEROUT and HSERIN are already taken. Using a baud rate of 9600 instead of 19200 made a difference. It is now working fine. The USB Darrel's interrupt takes micro seconds to execute. I measured it once. I forgot the exact number, but it was very small. That shouldn't affect the SEROUT/SERIN.
    "No one is completely worthless. They can always serve as a bad example."

    Anonymous

  8. #8
    Join Date
    Aug 2011
    Posts
    414


    Did you find this post helpful? Yes | No

    Default Re: SERIN2 Receiving Wrong Data

    From an old DT post (https://www.picbasic.co.uk/forum/sho...roblem?p=90526)

    Anytime you are using interrupts (other than ON INTERRUPT), it interrupts things.
    USB_ASM_Service uses USB interrupts that happen quite frequently.

    Software timed routines like SEROUT2, PAUSE, PULSIN/OUT etc. Will lose time that they don't know about.

    When using interrupts, Hardware devices should be use instead of software commands.
    Instead of SEROUT2, use HSEROUT with the USART.

    PAUSE ... use a timer.
    PULSIN ... use a CCP module.
    COUNT ... use a Timer

    There are still many PBP commands you can use without problems.
    But, if if they require specific timing thru software, that timing will be disturbed.

  9. #9
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    654


    Did you find this post helpful? Yes | No

    Default Re: SERIN2 Receiving Wrong Data

    Quote Originally Posted by tumbleweed View Post
    Yes, that explains everything. Unfortunately, I can't use the HSERIN/HSEROUT ports available in the 18F4550 because they are already taken doing the hardware communication. Increasing the baud rate worked.
    "No one is completely worthless. They can always serve as a bad example."

    Anonymous

Similar Threads

  1. Replies: 6
    Last Post: - 19th August 2013, 11:22
  2. how to display data receiving from xbee to LCD
    By NURULHAIZA in forum mel PIC BASIC
    Replies: 2
    Last Post: - 19th November 2010, 21:24
  3. Sending/receiving data using Linx modules
    By Goat 403 in forum Serial
    Replies: 3
    Last Post: - 21st May 2009, 13:57
  4. Receiving and Transmitting Serial data at the same time
    By BobP in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 12th April 2007, 22:00
  5. Receiving data from more than one serial Port
    By PICtron in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 15th March 2005, 10:20

Members who have read this thread : 17

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