Is there a wise way to debug a large code?


Closed Thread
Results 1 to 28 of 28

Hybrid View

  1. #1
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    967


    Did you find this post helpful? Yes | No

    Default Re: Is there a wise way to debug a large code?

    If you want goto premakro to run when ticker>=150, perhaps you need to reframe that part with the else....endif

    I wouldn't mind looking over the code if you want.

  2. #2
    Join Date
    Feb 2013
    Posts
    1,124


    Did you find this post helpful? Yes | No

    Default Re: Is there a wise way to debug a large code?

    "premakro" works fine, when I press a button, it gets called.
    The issue as I see, that somehow, HPWM statement, when duty cycle is less than 100%, disrupts the code.
    I'm using hardware PWM generators at PORTC.1 for brightness control PWM, and PORTC.2 for alarm buzzer sound

  3. #3
    Join Date
    Feb 2013
    Posts
    1,124


    Did you find this post helpful? Yes | No

    Default Re: Is there a wise way to debug a large code?

    I modified DIMMER subroutine and set it to always make 255 duty cycle - then nothing fails. So how to relate these things together?

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: Is there a wise way to debug a large code?

    How often is dimmer called? Every hour, every minute, every time thru the main loop?
    What if you make it always outout a dutycycle of 200, which is what it's getting set to 18.00 when the problem starts? Perhaps you have a hardware issue?

    Also, as a test try to get rid of the "one-liners" and do:
    Code:
    IF Z2=06 THEN
      HPWM 2,150,2000
    ENDIF
    
    IF Z2=08 THEN
      HPWM 2,200,2000
    ENDIF
    /Henrik.

  5. #5
    Join Date
    Feb 2013
    Posts
    1,124


    Did you find this post helpful? Yes | No

    Default Re: Is there a wise way to debug a large code?

    DIMMER gets called every second. I can fix this, but issue happens each minute, not second.
    I tried inserting HPWM 1,200,2000 at random places in main loop - no issues. They only happen when that DIMMER sub is being called.
    For the one-liners, they're great way to save yourself from a lot of scrolling, I'm writing code in that way for last 40 years, so I don't think that now is the time to change.
    For the hardware issue, ADC reading is done at PORTA.0 and PWM output is at PORTC.1, so I don't think this can be a RMW issue.

    The main loop can be divided into the following sections:

    1. Get current time (read RTC)
    2. If oldminute<>currentminute, then go seganime (animate all segments at each 1 minute change)
    3. Convert hours into Z2
    4. If autodim is enabled, then goto dimmer
    5. alarm check and call subroutine
    6. 12/24 hour check and conversion subroutine
    7. Display current time routine
    8. Keyboard handling code (ADC reading and debouncing)
    9. middle dot blinking

  6. #6
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: Is there a wise way to debug a large code?

    4. If autodim is enabled, then goto dimmer
    GOTO?

    For the one-liners, they're great way to save yourself from a lot of scrolling, I'm writing code in that way for last 40 years, so I don't think that now is the time to change.
    OK but I thought we've showed by now that PBP is not "the same" as interpreted BASIC on you ZX Spectrum from '82.If you're sure that your one-liners work then fine but you wanted suggestion on how to debug the code and I was trying to give you ideas on what to try but never mind.

Similar Threads

  1. DEBUG DEC DatVar vs DEBUG #DatVar
    By netstranger.nz in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 16th March 2011, 21:26
  2. Replies: 0
    Last Post: - 18th November 2010, 18:50
  3. How does everyone debug their code?
    By HankMcSpank in forum General
    Replies: 30
    Last Post: - 18th June 2009, 06:41
  4. SERIN from a large string
    By earltyso in forum Serial
    Replies: 5
    Last Post: - 2nd May 2008, 22:23
  5. large displays
    By George in forum Off Topic
    Replies: 2
    Last Post: - 18th March 2007, 21:56

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