Serial comunication problem


Closed Thread
Results 1 to 23 of 23
  1. #1
    Join Date
    Sep 2011
    Posts
    20

    Default Serial comunication problem

    Hi,

    I have a very silly problem with a my very simply
    prog in PBP.

    I got a easy circuit with a 16f676 PIC and a IC Maxim 232
    all fitted on a breadboard, where I simply send data(string, variables, ecc)
    to COM1: on my PC, with Debug instruction at 2400B and using Hyperterminal
    on Win-XP.

    The problem is the I get back just a lot of garbage on my
    screen(unreadable chars) and I can't visualizy any ASCII
    code!

    I have checked a very lot of times my circuit, changed
    the IC, verified the voltage, the pins on RS-232, change
    the serial port, the prog in PBP, but it seems is correctly
    and all is too simply to be wrong.
    I have checked with a LCD if PIC/Prog work and yes it's
    work perfectly, but I can't send anything on my PC's
    serial port.

    Maybe I need to set the RS-232 DTR, DCD, ecc in anyway ?

    So please help my to solve it because I think to forget
    to do some elementar thing.

    Thanks in adavance.

    PS:
    Forget my english.

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: Serial comunication problem

    Hi,
    Have you tried changing mode for DEBUG, true vs inverted?
    Code:
    DEFINE DEBUG_MODE 0   'or 1 (I can't remember which one at the moment)
    /Henrik.

  3. #3
    Join Date
    Dec 2009
    Location
    Annapolis, MaryLand, USA
    Posts
    1


    Did you find this post helpful? Yes | No

    Default Re: Serial comunication problem

    A couple of other things to check are the charge pump capacitors that you are using with your RS-232 chip and your circuit grounds.

  4. #4
    Join Date
    Dec 2010
    Posts
    409


    Did you find this post helpful? Yes | No

    Default Re: Serial comunication problem

    Based on your description, the data is either inverted, or being sent at the wrong speed. Verify setting match in both your code and on the PC, (for example 9600,8,N,1) and then check your clock on the PIC is correct. The speeds specified in PBP are only valid with a certain clock (4 MHz off the top of my head). You should not need to set DTR, or DCD. Final thing to check is that the RS232 cable is connected properly. If you have not crossed TX to RX, sometimes noise with give screens of garbage.

  5. #5
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: Serial comunication problem

    Also, make certain that Hyperterm is set for Flow Control = None
    Charles Linquist

  6. #6
    Join Date
    Oct 2004
    Posts
    448


    Did you find this post helpful? Yes | No

    Default Re: Serial comunication problem

    Are you adding the '#' before the variable?

    And if you are using the built-in oscillator on the 16F676, are you sure your OSCCAL value is correct?

    Regards,

    Anand

  7. #7
    Join Date
    Sep 2011
    Posts
    20


    Did you find this post helpful? Yes | No

    Default Re: Serial comunication problem

    Firs one thanks to all for fast answer.
    Yes I have checked all things posted and a lot of times.
    But nothing work.

    Maybe is a problem with a Breadboard thet collect noise ?

    I know it hard to say what check, but all seem fine and at
    same time nothing work!

    I am very confused because I have made a lot o circuit
    with PIC in assembler and basic, with motor, with display,
    with PWN dimmed ligght, and ever have worked fine,
    but now with a silly serial debugging purpose nothing
    work.
    I am very frustated!
    Last edited by synsyn; - 30th September 2011 at 21:01.

  8. #8
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: Serial comunication problem

    Post you code and configs along with a schematic.
    Everyone is guessing as is.
    Dave
    Always wear safety glasses while programming.

  9. #9
    Join Date
    Sep 2011
    Posts
    20


    Did you find this post helpful? Yes | No

    Default Re: Serial comunication problem

    Hello,
    Thank for reply and sorry for the late to answer but I was away for job.

    I don't have much to to make experiment but I have try to change the
    cable and the main circuit.
    All is same I will get back the same garbage but...

    Now i try to send the word "Hello" and now I get back on screen PC the
    exact number of chars but with non ascii format like '¨µ¼´¿".

    Yesterday I don't know how, maybe some change to prog or same hack
    on circuit, for a short time I have get back the correct string on screen!
    "hello"hello"hello"...

    After that I have made some change and now all is come back in the
    same garbage!

    In anyway this is the source:
    ------------------------------------------------------------------------------
    ANSEL=0
    CMCON=7



    TRISA = %11110000 ' Set PORTA to all input
    TRISC = %00000000 ' Set PORTA to all input


    Include "modedefs.bas"

    DEFINE OSC 4

    DEFINE DEBUG_REG PORTC
    DEFINE DEBUG_BIT 1
    DEFINE DEBUG_BAUD 2400
    DEFINE DEBUG_MODE 0

    DEFINE DEBUG_PACING 1000

    Clear
    Pause 1000

    Cont var Byte

    Cont = 0
    Mainloop
    PAUSE 1000
    Cont = Cont + 1
    Debug "Hello"
    PORTC.2 = 1
    PAUSE 1000
    PORTC.2 = 0
    goto Mainloop
    ------------------------------------------------------------------------------
    And this the circuit:

    Name:  Scheme.JPG
Views: 636
Size:  40.3 KB

  10. #10
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: Serial comunication problem

    I see you have a LED set to blink on for 1 sec, then off for 1 sec. Is the LED blinking and at the correct speed?
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  11. #11
    Join Date
    Sep 2011
    Posts
    20


    Did you find this post helpful? Yes | No

    Default Re: Serial comunication problem

    Hi Bert,

    I have fogot to say, it is only a luminose control to see if all work well(I don't have put it on the scheme).
    And yes it seem blink 1 sec and 1 sec no. It's hard to say just lookin at it
    but the time seem correct yes.

  12. #12
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: Serial comunication problem

    Well that would seem to rule out any OSC issues. The Pic is running and running at 4Mhz as you have programmed for. At this point, I think I would just have it run and start touching stuff. Maybe there is a breadboard problem or something like that. If it worked yesterday, even just for a few times, it seems like the code is good. So the only thing left is hardware.

    Wiggle the caps while watching the PC to see if "hello" magically appears. also all the wires. Do this 1 at a time to try and isolate the problem.

    Maybe even try a different output pin, Or move the parts around on the BB. I have had BB's fail on a pin here and there from the socket not making good contact.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  13. #13
    Join Date
    Sep 2011
    Posts
    20


    Did you find this post helpful? Yes | No

    Default Re: Serial comunication problem

    Quote Originally Posted by cncmachineguy View Post
    Well that would seem to rule out any OSC issue
    Yes I think the problem is there, but maybe in the code or maybe I dont' sent
    some registry of 16f676 IC.

    I say this because I have change the PIC circuit in a 1000hole board and I get
    the same garbage.
    I think to have change something in the code about OSC define or something
    aroud and the serial work.
    I anyway I can wrong, but the only thing ever same is the MAX232 circuit,
    but there is only some condensator so I can see any thing wrong.

    Maybe some one have made the same circuit with PIC 16f676 and Max232
    and he can check if the code, expeccialy the Oscillator define, is correct ?

  14. #14
    Join Date
    Oct 2004
    Posts
    448


    Did you find this post helpful? Yes | No

    Default Re: Serial comunication problem

    Why dont you try bypassing the Max232 and use Debug Mode 1 to rule that out?

    And I just noticed you're using the 16F676; are you sure your OSCCAL value is intact?

    Check this outhttp://www.picbasic.co.uk/forum/showthread.php?t=15268

    Regards,

    Anand Dhuru

  15. #15
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: Serial comunication problem

    You can do a pretty good "no equipment" check of your oscillator by turning ON a LED, issuing a PAUSE 60000 and then turning it off. Even with human error, if it is ON for a minute, you should be within 2%, which is close enough for communications at 9600 baud. If you want to get even closer, issue the PAUSE 60000 10 times in a row. Turn your LED on at the beginning and off at the end. It takes 10 minutes, but you can easily get much better than .5% accuracy that way. The PBP PAUSE command is *VERY* accurate.

    Also, I highly recommend Bray's terminal program
    https://sites.google.com/site/terminalbpp/

    It works with high-numbered COM ports (useful if you are using USB <-> 232 devices). It works with
    Windows 7 (which does NOT have Hyperterminal), and best of all
    It lets you choose non-standard baud rates. If your PIC is running 5% fast, you can choose 1080 baud if
    you like (not all baud rates may be attainable with all hardware, but the software does a great job).
    Charles Linquist

  16. #16
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: Serial comunication problem

    Oh, and QUIT using those 16F chips! 18Fs are so much better and don't cost any more.
    Charles Linquist

  17. #17
    Join Date
    Oct 2004
    Posts
    440


    Did you find this post helpful? Yes | No

    Default Re: Serial comunication problem

    Quote Originally Posted by Charles Linquis View Post
    Oh, and QUIT using those 16F chips! 18Fs are so much better and don't cost any more.
    I second that.

    Norm

  18. #18
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: Serial comunication problem

    Not to continue hi-jacking this thread, but I have to a little. What is so bad about the 16F's? They are easier to configure if you are new to datasheets, work just as well (both 8 bit). OK, less memory, but who needs it for starting out stuff? I have a couple of products running 16f676 that have been going strong now for 8 years I think. Work fine!

    I am starting to play with the 18's, but really just because.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  19. #19
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: Serial comunication problem

    Yes they work, but the forum would run a little smoother if most everyone was using the same series of chip. I'm sure MELabs thinks that way also.
    The fact that you can easily get parts with large codespace is such a bonus. You can add features over the years without
    changing much.
    90% of Microchip's really neat parts in the 8-bit realm are in the 18F family (18FxxKxx, 18FxxJxx).
    If you write some routines in ASM, it is much nicer to not have to deal with endless bank switching.
    You can use LONGs and 2000 element arrays.
    Even if you don't need all the neat stuff now, why not get a chip that has the peripherals and codespace now so that you can learn to use the extra features in your spare time?

    And they don't cost more. Easy decision for me. I'll be quiet now.
    Charles Linquist

  20. #20
    Join Date
    Sep 2011
    Posts
    20


    Did you find this post helpful? Yes | No

    Default Re: Serial comunication problem

    All Solved!!!

    I know that the issue was on Clock, or better, in wrong clock serial syncronization.
    So I have change the Internal Oscillator with a External quarze and made the code
    changing to use it. Now all work very good and without any problem.
    I have take a look on 16f676 Datasheet where is writted than internal clock have a
    little tollerance about on some kilohert. But in other forum discussion I have found
    than the internal clock is barely enought in use on serial asyncronous comunications.
    This is my case.
    Maybe if I work on OSCCAL calibration I will use the Internal clock.
    But if I put OSSCAL issue on Picbasic source the PBP give a error, like if OSSCAL is
    not avaible on 16f676.
    I have lost a week on this problem but now all is over and in anyway I have get more
    experience about use and expecially the "non-use" of internal oscillator for some specified
    task like comunications, where is very important have a good timing.
    Thank to all friends to have spend their time on this post and for goods solution proposed
    to me.
    This forum is a very good mine of competent and friendly people. I will hope to give some
    contribution in future.
    Thanks again.

  21. #21
    Join Date
    Sep 2011
    Posts
    20


    Did you find this post helpful? Yes | No

    Default Re: Serial comunication problem

    Quote Originally Posted by ardhuru View Post
    And I just noticed you're using the 16F676; are you sure your OSCCAL value is intact?

    Check this outhttp://www.picbasic.co.uk/forum/showthread.php?t=15268

    Regards,

    Anand Dhuru
    Hi Anand,
    I have tried today your example and I did some experiment,
    and of corse it works very good!!!
    It's a easy way to use the PIC with internal oscillator
    in serial comunications, or other critical tasks where timing
    is crucial, without the use of an external quartz.
    Thanks a lot for your advice.
    Regards,
    Gabriele

  22. #22
    Join Date
    Oct 2004
    Posts
    448


    Did you find this post helpful? Yes | No

    Default Re: Serial comunication problem

    Glad it helped, Gabriele. Now that you have the calibrated OSCCAL, you could fairly safely ramp up the baud to 9600.

    Regards,

    Anand

  23. #23
    Join Date
    Sep 2011
    Posts
    20


    Did you find this post helpful? Yes | No

    Default Re: Serial comunication problem

    Oh Yes now I can Burd the Sky!!!
    Thanks again to have helped me and for knowing on forum.

Members who have read this thread : 1

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