How do I use DEBUG ?


Closed Thread
Results 1 to 14 of 14

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    O.k.. DEBUG in PBP is about the same than SEROUT BUT it take less of your code space. If you want to use DEBUG you'll have to define few things before it work properly to send data to your PC without any kind of MAX232 or else inverter chip

    1. set the baudrate
    DEFINE DEBUG_BAUD 2400

    2. set inverted mode
    DEFINE DEBUG_MODE 1

    3. set the DEBUG serial out pin
    DEFINE DEBUG_REG PORTB
    DEFINE DEBUG_BIT 0 'These two line will set your debug out on the PORTB.0

    Once its done you'll be able to send your data in serial to your PC with
    DEBUG #MyVar

    this will send the ascii representation of MyVar value.

    If you want to send with SEROUT on PORTB.0 at 2400 baud inverted
    SEROUT PORTB.0,4,[#Myvar]

    Both of the above will work with a simple 1k in serie with the PIC to the pin2 of your DB9 connector.
    Code:
    TRISB=0
    DEFINE DEBUG_BAUD 2400 
    DEFINE DEBUG_MODE 1
    DEFINE DEBUG_REG PORTB
    DEFINE DEBUG_BIT 0 'These two line will set your debug out on the PORTB.0 
    MyVar var byte
    clear
    start:
         DEBUG "MyVar=",#MyVar,13,10
         pause 500
         if MyVar<255 then 
              MyVar = MyVar + 1
         ELSE
              Myvar = 0     
         ENDIF
         goto start
    You can monitor everything in the MicroCode Studio Serial window or in Hyperterm, RealTerm or else terminal program.
    Last edited by mister_e; - 21st February 2005 at 18:56.
    Steve

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

  2. #2
    Join Date
    Feb 2005
    Location
    Toronto, Canada
    Posts
    46


    Did you find this post helpful? Yes | No

    Default

    WOW! WICKED!! thanks man!

    debug was the final and LAST reason I was hanging onto my Basic Stamp2 for prototyping. time to sell it and say goodbye to it forever!!

    oh, also, just outa curiosity, is there any preferance as to what pin the debug is used on? porta or B?

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


    Did you find this post helpful? Yes | No

    Default

    No. since your selected pin can be an output and it's not an open drain type (like many RA4) it will work without anything else than 1 resistor.
    Steve

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

  4. #4
    Trent's Avatar
    Trent Guest


    Did you find this post helpful? Yes | No

    Default More questions about DEBUG command

    Quote Originally Posted by mister_e View Post
    O.k.. DEBUG in PBP is about the same than SEROUT BUT it take less of your code space. If you want to use DEBUG you'll have to define few things before it work properly to send data to your PC without any kind of MAX232 or else inverter chip

    1. set the baudrate
    DEFINE DEBUG_BAUD 2400

    2. set inverted mode
    DEFINE DEBUG_MODE 1

    3. set the DEBUG serial out pin
    DEFINE DEBUG_REG PORTB
    DEFINE DEBUG_BIT 0 'These two line will set your debug out on the PORTB.0

    Once its done you'll be able to send your data in serial to your PC with
    DEBUG #MyVar

    this will send the ascii representation of MyVar value.

    If you want to send with SEROUT on PORTB.0 at 2400 baud inverted
    SEROUT PORTB.0,4,[#Myvar]

    Both of the above will work with a simple 1k in serie with the PIC to the pin2 of your DB9 connector.
    Code:
    TRISB=0
    DEFINE DEBUG_BAUD 2400 
    DEFINE DEBUG_MODE 1
    DEFINE DEBUG_REG PORTB
    DEFINE DEBUG_BIT 0 'These two line will set your debug out on the PORTB.0 
    MyVar var byte
    clear
    start:
         DEBUG "MyVar=",#MyVar,13,10
         pause 500
         if MyVar<255 then 
              MyVar = MyVar + 1
         ELSE
              Myvar = 0     
         ENDIF
         goto start
    You can monitor everything in the MicroCode Studio Serial window or in Hyperterm, RealTerm or else terminal program.

    What does
    DEBUG "MyVar=",#MyVar,13,10
    do? What is the 13, 10?

    Thanks- Trent

  5. #5
    Join Date
    Mar 2005
    Location
    Iowa, USA
    Posts
    216


    Did you find this post helpful? Yes | No

    Default

    Trent -
    The 13,10 are the decimal equivalents of Carriage Return (CR) and Line Feed (LF) control characters. So each time you send the command to hyperterminal it will be nice and neat on seperate lines.
    Wisdom is knowing what path to take next... Integrity is taking it.
    Ryan Miller

  6. #6


    Did you find this post helpful? Yes | No

    Default

    One question concerning debug command.

    With which BAUD rates can it be used ?

    .

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


    Did you find this post helpful? Yes | No

    Default

    Dave
    Always wear safety glasses while programming.

  8. #8


    Did you find this post helpful? Yes | No

    Default

    Thank's Dave

    .

Similar Threads

  1. N-Bit_MATH
    By Darrel Taylor in forum Code Examples
    Replies: 38
    Last Post: - 16th December 2010, 14:48
  2. Wireless using debug.
    By polymer52 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 18th January 2010, 14:53
  3. About USB
    By dias11 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 3rd December 2009, 20:41
  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 : 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