How does everyone debug their code?


Closed Thread
Results 1 to 31 of 31

Hybrid View

  1. #1
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Well, I've after two solid nights battling to get my PIC 16F690 to talk to the outside world...I've got it working

    I decided I really did want some form of serout command (that I could call on demand), therefore last night I messed about with a MAX232 for a couple of hours....no success (I now realise that this was becuase I was feeding the MAX232 just 3V...sourced from the PICKIT2 VCC - it needs 5V - doh! Thanks to DavyJones for emailing me the schematics)

    Anyway, the post that mister_e madecaught my attention - & I've ended up going that route. I now have PIC program going outputing to the UART window (within the PICKIT app - altough it's a little clunky if you ask me). I 've actually pimped my PICKIT2 board by soldering on a little switch which allows me to quickly switch between the PICKIT as a 'programming device' & the PICKIT 2 as a 'serial interface device' ....so no need to change the PICKIT2 edge connector now :-)

    Anyway, I'm on the final straight...my query now relates to Terminal Window formatting (or rather whatever it takes to get the PICKIT 2 UART window to clear down!)

    Can anyone outline (in simple terms), how I can send simple 'clear screen', line feed commands etc using the HSEROUT command?

    here's a little of my code (you've not to laugh!)

    ADCIN 0, DC_Level_IN ; Read the DC level on RA0 (pin 19)
    HSEROUT ["ADCIN Value = ", DEC DC_Level_IN]


    The problem with the above method is it's very hard on the eyes, as ithe data progresses across the screen left to right. Ideally I'd like each update to appear on a new line (or even just totally clearing the screen before the data is updated each time)

    Many thanks in anticipation.

    Hank.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by HankMcSpank View Post
    ADCIN 0, DC_Level_IN ; Read the DC level on RA0 (pin 19)
    HSEROUT ["ADCIN Value = ", DEC DC_Level_IN]


    The problem with the above method is it's very hard on the eyes, as ithe data progresses across the screen left to right. Ideally I'd like each update to appear on a new line (or even just totally clearing the screen before the data is updated each time)

    Many thanks in anticipation.

    Hank.
    Try:
    [code]
    HSEROUT [254,1,"ADCIN Value = ", DEC DC_Level_IN]
    [code]
    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.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by HankMcSpank View Post
    ADCIN 0, DC_Level_IN ; Read the DC level on RA0 (pin 19)
    HSEROUT ["ADCIN Value = ", DEC DC_Level_IN]


    The problem with the above method is it's very hard on the eyes, as ithe data progresses across the screen left to right. Ideally I'd like each update to appear on a new line (or even just totally clearing the screen before the data is updated each time)

    Many thanks in anticipation.

    Hank.
    Try:
    Code:
    HSEROUT [254,1,"ADCIN Value =  ", DEC DC_Level_IN]
    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.

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


    Did you find this post helpful? Yes | No

    Default

    Damn, need the edit feature back . .
    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.

  5. #5
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Thanks for trying to help me out Joe, but it didn't solve my problem...



    (though I'm seeing lots of little rectangles after the data onscreen now - perhaps such unexpected results is a quirk of Microchips' UART tool window?)

  6. #6
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    This works intermittedly...

    HSEROUT [10,13," Increase Gain, ADCIN Value = ", DEC DC_Level_IN]

    ...about 4 times out of 10, I get a new line!

    I've tried changing the baud

    DEFINE HSER_BAUD 2400

    ...but I just get garbage when i do (yes, I'm changing the setting in the UART window too!). therefore I'm thinking this might the general flakiness of the internal oscillator &/or the quirkiness of the Microchip UART window?

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by HankMcSpank View Post
    This works intermittedly...

    HSEROUT [10,13," Increase Gain, ADCIN Value = ", DEC DC_Level_IN]

    ...about 4 times out of 10, I get a new line!

    I've tried changing the baud

    DEFINE HSER_BAUD 2400

    ...but I just get garbage when i do (yes, I'm changing the setting in the UART window too!). therefore I'm thinking this might the general flakiness of the internal oscillator &/or the quirkiness of the Microchip UART window?
    Have you tried sending 2 separate lines, 1 to clear or give a newline and the second with your data? I would put a little pause in between too. You might research CHAR_PACING too
    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.

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


    Did you find this post helpful? Yes | No

    Default

    In this order.
    hserout [whatever data, 13,10]

    this will work all the time as long as you have sufficient delay between all your HSEROUT, and as long as your baudrate is accurate.

    What you want is a ANSI terminal, those who accept ESC character, like the boring Hyperterminal, TeraTerm, RealTerm to name only but those. With an ANSI terminal, you can clear the screen, change font color, background color etc etc etc ( see http://www.pbpgroup.com/modules/wfse...hp?articleid=9 for reference)

    Unfortunately, PICKIT USART tool is not an ANSI one, so you have to deal with the pain or work around. If you're a bit familiar with Microsoft C#, you could modify Pickit USART tool (as it is open source anyways) to accept ESC characters, or to clear the screen when you receive, let's say, ASCII 225 or whatever else. That should be easy.
    <hr>
    I'll redo my explanation about USART tool debugging...

    Unless your current hardware don't use Serial communication, there's no need to use a switch, no need for HSEROUT either. What you do is to sit your PICKIT on the regular programming pins (MCLR, PGD, PGC) all the time, then you use DEBUG/SEROUT/SEROUT2 on PGD I/O. For this you must use TRUE mode.

    Clear enough now?

    I may try to post an example before going to sleep.
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by HankMcSpank View Post
    Thanks for trying to help me out Joe, but it didn't solve my problem...

    (though I'm seeing lots of little rectangles after the data onscreen now - perhaps such unexpected results is a quirk of Microchips' UART tool window?)
    I misread your post, I thought you were sending to a serial LCD.
    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.

Similar Threads

  1. N-Bit_MATH
    By Darrel Taylor in forum Code Examples
    Replies: 38
    Last Post: - 16th December 2010, 14:48
  2. debug not working with MPASM assempler
    By santamaria in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 4th March 2009, 07:51
  3. How much code space do PBP statements use.
    By Darrel Taylor in forum Code Examples
    Replies: 5
    Last Post: - 13th February 2009, 21:31
  4. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  5. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26

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