Random Serin/Serout issues


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    May 2011
    Posts
    42

    Default Random Serin/Serout issues

    I have run across a problem with Serin/Serin2 and Serout/Serout2 to a lesser extent that has been driving me nuts for the last few days. I am guessing it has to do with my configuration and I have tried about 1000 different combinations to no avail.

    Here is the problem. On a 16F1826 and an 18F1320 the following code does not return any data but does not stop and wait for the timeout. The code blows through the timeout like there is data there but there isn't. I went down the road of noise on the line to the extent of removing the Xbee that is talking to it and pulling the Serin pin both high and low and changing from true to inverted through a variety of resistors down to 47 ohms with no change in the code's behavior. On the 1320 but not the 1826 I can change the Serin pin to A.2 and it works fine. To confuse it more, a 16F628A works just fine with the same code (changing the osc values and registers to accommodate the different PICS). The code shown is the working code for the 628A with a bunch of stuff commented out that I was using while trying different combinations for the other two PICS.

    Include "modedefs.bas"
    'CMCON = 7
    'ADCON1=7
    'define OSC 8
    ' osccon = %01111110
    'OSCCON=%01101010 1826
    TRISA=%11111111 ' Set PortA to Output

    trisb=%11111111 'Enable internal pull ups

    Command var byte

    Do

    serin2 portb.4,396, 1000, mainpass,[command]
    'if command = "R" then
    'pause 100
    serout2 portb.5, 396, ["5"]
    high porta.3
    pause 200
    low porta.3
    'endif

    mainpass:
    Loop


    Maybe unrelated but I had a similar issue with an 18F2525 and Serout. A port C pin would work in the first instance it was used but after a few unrelated IO routines it would stop working (scope showed nothing going on during the time serial data was supposed to be sent). However, it worked just fine on another port C pin. I wish I remember the specifics but I just changed the circuit board to use a different pin. I was hoping if somebody smart enough to straighten me out on the above problem they might have insight as to why one pin would work but the other wouldn't so I don't have to blow a few hundred $ getting board reprints if it happens in the future.

    Thanks in advance for any help you can provide.

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: Random Serin/Serout issues

    You need to enable Digital Inputs on the Analog pins.

    ;_16F1826_
    ANSELA = 0
    ANSELB = 0

    ;_18F1320_
    ADCON1 = $7F

    ;_18F2525_
    ADCON1 = $0F
    DT

  3. #3
    Join Date
    May 2011
    Posts
    42


    Did you find this post helpful? Yes | No

    Default Re: Random Serin/Serout issues

    That seems to have done it and I don't know why I missed that. I suppose it may be because I have done projects on the 628A exclusively until now and didn't read about the liabilities that come with the new capabilities of the PICS I am working with now. Thanks again.

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: Random Serin/Serout issues

    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Re: Random Serin/Serout issues

    Quote Originally Posted by Szczepaniec View Post
    . . . . and didn't read about the liabilities that come with the new capabilities of the PICS I am working with now. Thanks again.
    This seems to ME to be the # 1 mistake of new members. You are in really good company. People in this forum have asked the question " why does anybody use or recommend the old grandpa 16F84 chips ? I would submit it is for the very reason as posted here, no registers require setting to disable analog. Reading data sheets requires some thought and understanding, or at least learning to read them, and although they usually do make sense it takes a while before the really do.
    Best Regards
    JS
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

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