Ascii debug issues?


Closed Thread
Results 1 to 12 of 12
  1. #1
    achilles03's Avatar
    achilles03 Guest

    Default Ascii debug issues?

    I had a program that communicated via RS232 to my PC pretty well, but I lost it in a hard drive transfer and can't get a new program to work exactly right.

    The program I have has the following serout2 command repeated in a loop:

    serout2 portb.2,396,["TACOS"]

    On my terminal program, all I get is something like:
    "aeU aeU aeU aeU aeU"

    (the a is actually a Greek alpha)

    I've also tried (with somewhat similar results as above):
    serout2 portb.2,396,[DEC 84,65,67,79,115,33,13]

    I have the terminal program set to recieve at 2400, true, non-inverted, 8-bit and 1 stop bit. What am I missing?

    Thanks in advance for any help!
    Dave

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


    Did you find this post helpful? Yes | No

    Default

    what about the osc speed? if different than 4MHZ, did you use the DEFINE OSC ???
    Steve

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

  3. #3
    achilles03's Avatar
    achilles03 Guest


    Did you find this post helpful? Yes | No

    Default

    Yeah, I set it to 4Mhz.

  4. #4
    Join Date
    Sep 2005
    Location
    Dayton, Ohio
    Posts
    72


    Did you find this post helpful? Yes | No

    Default

    I am suffering a similar problem here with a PIC18F2525. I know the MAX232 interface is fine, as it works perfect for bootloading. And I can get HSEROUT to work fine, but when I try to use SEROUT I get wierd characters on hyperterminal.

    I am runnig at 8MHz with a ceramic resonator (yes I use DEFINE OSC 8) and using 9600 baud.

    I'm wondering if it's a timing issue with software vs hardware generated serial data. I still need to try generating from other pins. Possible that the USART is still doing something to the TX pin due to the bootloader having configured it. Still troubleshooting ....
    Jim Robertson
    "MilesTag" DIY Lasertag
    www.lasertagparts.com/mtdesign.htm
    Dayton, Ohio

  5. #5
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Are you using TRUE mode with SEROUT?

    Going through the MAX232 you'll need to use TRUE mode. With a direct connection to the PC, you would use inverted.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

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


    Did you find this post helpful? Yes | No

    Default

    In addition to Bruce, what about the config fuses? HS OSC or XT OSC???
    Steve

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

  7. #7
    Join Date
    Sep 2005
    Location
    Dayton, Ohio
    Posts
    72


    Did you find this post helpful? Yes | No

    Default

    For mine, I am using T9600 for SEROUT. And Hyperterm is set to 8N1.

    Oscillator config fuse is set to XT (done in the bootloader firmware).

    As I said, HSEROUT works perfectly. The bootloader runs smoothly at 19200, then I use the DEFINES in the PBP program to set the USART to 9600 baud.

    I WILL find the problem....eventually . I haven't exhausted all of my methodical troubleshooting options yet. And I have a bit more reading up on the USART. It's possible I can just use the USART once I learn how to quickly switch between USART and using the pin as a digital I/O.

    But it concerns me that I can't get the the software serial routines to put out anything but apparent garbage. And it's probably the same thing that is causing problems for Achilles.
    Last edited by milestag; - 17th November 2005 at 19:19.
    Jim Robertson
    "MilesTag" DIY Lasertag
    www.lasertagparts.com/mtdesign.htm
    Dayton, Ohio

  8. #8
    achilles03's Avatar
    achilles03 Guest


    Did you find this post helpful? Yes | No

    Default

    I'm still having a rough time getting mine to communicate correctly. I've even tried 2 different PICs (12F629 and a 16F628). Below is the code I'm using for the 629:

    ______________________________________
    cmcon=7

    define osc 4

    loop:
    serout GPIO.0,3,[84,97,99,111,10,13]
    pause 50
    low portb.1
    pause 50
    high portb.1
    Goto loop
    ______________________________________

    However, here is the output I get:
    http://www.geocities.com/achilles03/debug.jpg

    I'm running it off the internal osc. Is it possible the frequency of the internal osc varies enough to result in an unintelligible output?

    I've also tried different baud rates and serout2, but with similar results (for both PICS). Can anyone see anything obvious, like some sort of conversion or program omission, that I'm doing wrong? I'd appreciate any advice.

    Dave
    Attached Images Attached Images  

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


    Did you find this post helpful? Yes | No

    Default

    with 8MHZ osc, you must set the config fuse to HS osc. Bruce already spot on the problem cause...
    Quote Originally Posted by bruce
    Going through the MAX232 you'll need to use TRUE mode. With a direct connection to the PC, you would use inverted.
    Souds really like a bad Inverted/True mode to me.
    Steve

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

  10. #10


    Did you find this post helpful? Yes | No

    Default

    Do you have a null modem in your PIC to PC cable?

  11. #11
    achilles03's Avatar
    achilles03 Guest


    Did you find this post helpful? Yes | No

    Default

    I have pin 2 (PIC side) connected to pin 3 (PC side), and pin 5 (GND) on both connected. I also have pins 7 and 8 connected on the PC side.

  12. #12
    Join Date
    Sep 2005
    Location
    Dayton, Ohio
    Posts
    72


    Did you find this post helpful? Yes | No

    Default

    Achilles,
    A little while back, I saw a post by Melanie that stated you MUST use a crystal or resonator for reliable PIC to PC async comms. I would say this is ESPECIALLY true for a PIC12F629. Might do better with a 12F683 which has 1% accuracy internal osc (factory calibrated) without the need for reading and restoring an oscal value.

    I ended up doing some last minute changes to my PC board design (luckily BEFORE I did a production run) in order to incorporate the resonator.

    BTW - sorry...I feel like I hijacked your thread. But we may have similar problems. I see similar nonsense characters on HYPERTERM and on the TINY BOOTLOADER terminal.

    Mister_e, Dick,
    Thanks, I'll try the HS OSC setting. But, as I said, the HSEROUT works fine at 9600 baud and the bootloader works fine at 19200. Same project....I'm just trying to add the SEROUT command to my program for debugging.

    I am going through a MAX232, and using TRUE mode. I've tried true and inverted. It is a straight-through cable, and I don't change any connections between HSEROUT and SEROUT. I just comment out all the HSEROUT DEFINEs while I try the SEROUT command.

    I also tried DEBUG, but for some reason MPASM (which I must use for 18F2525) generates an error that I am attempting to redefine "DEBUG".

    Ultimately I will probably have to start with a simpler program with no bootloader, etc. That way I can isolate the PBP commands and PC interface. I think I am dealing with too many variables at this point (hardware AND software).

    Thanks for the help so far, guys. I'll try these things this weekend and post back here with results.

    -Jim
    Jim Robertson
    "MilesTag" DIY Lasertag
    www.lasertagparts.com/mtdesign.htm
    Dayton, Ohio

Similar Threads

  1. N-Bit_MATH
    By Darrel Taylor in forum Code Examples
    Replies: 38
    Last Post: - 16th December 2010, 14:48
  2. About USB
    By dias11 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 3rd December 2009, 20:41
  3. Understanding timer issues
    By boroko in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 7th April 2009, 02:56
  4. debug not working with MPASM assempler
    By santamaria in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 4th March 2009, 07:51
  5. Data EEPROM gets clobbered during programming
    By BrianT in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 18th July 2008, 02:46

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