• AVR Freaks
Reply to post

I am trying to understand some code that was written by an individual who passed away

Author
Tomragsdale
New Member
  • Total Posts : 4
  • Reward points : 0
  • Joined: 2013/04/16 15:02:25
  • Location: 0
  • Status: offline
2013/05/16 16:58:04 (permalink)
0

I am trying to understand some code that was written by an individual who passed away

 
The processor used is a PIC16HV610
ComputePWM is defined as bit 6 of RSStat Register.
three counters are defined:
TmOut0
TmOut1
TmOut2
What I don't understand is how ComputePWM is ever reset once it is cleared to allow the program to go thru the Run_A routine again.
This loop is part of a timer of sorts that allows the Run_A stuff to go through it's thing over and over for a defined time then go to sleep.
Here is the code in question:
MainLoop:
        btfsc   ComputePWM
        goto    Run_A           
        decfsz    TmOut0,1
        goto    MainLoop
        decfsz    TmOut1,1
        goto    MainLoop
        decfsz    TmOut2,1
        goto    MainLoop
        movlw    0x30
        movwf    _intcon
        clrwdt
        bcf        OutA
        bcf        OutB
        bcf        OutC
        bsf        _gie
        sleep
        goto    INI_PWM
        goto    MainLoop

4 Replies Related Threads

    DarioG
    Allmächtig.
    • Total Posts : 54081
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: Oesterreich
    • Status: offline
    Re:I am trying to understand some code that was written by an individual who passed away 2013/05/17 00:54:26 (permalink)
    0
    Hmm, where is ComputePWM defined? Maybe it's a hardware input?

    GENOVA :D :D ! GODO
    Tomragsdale
    New Member
    • Total Posts : 4
    • Reward points : 0
    • Joined: 2013/04/16 15:02:25
    • Location: 0
    • Status: offline
    Re:I am trying to understand some code that was written by an individual who passed away 2013/05/17 02:30:55 (permalink)
    0
    ComputePWM is defined in the .h file with the following statement:
     
    #define ComputePWM     RSStat,6        ; ComputePWM
     
    RSStat is declared in a list of registers in the same .h file:
    ;***************************************************************************
    ;        Register Definition
    ;***************************************************************************

            CBLOCK  0x40   
                        ;     16HV610
     
            CtlReg         ; 3 22
            PWMCount     ; 4 23 (0 to 255) PWM Counter
            HiTimeA         ; 5 24 (PWM Hi=On, Lo=Off, 255=100% DutyCycle, Output A)
            HiTimeB         ; 6 25 (PWM Hi=On, Lo=Off, 255=100% DutyCycle, Output B)
            HiTimeC        ; 7 26 (PWM Hi=On, Lo=Off, 255=100% DutyCycle, Output C)
            Status_A    ; 8 27
            Status_B    ; 9 28
            Status_C    ;10 29
           
            AoutPWM        ;68 63
            BoutPWM        ;69    64
            CoutPWM        ;70 65

            ATimeL        ;71 66 Temp Time Count Lo Byte
            ATimeH        ;72    Temp Time Count Hi Byte
            BTimeL        ;73    Temp Time Count Lo Byte
            BTimeH        ;74    Temp Time Count Hi Byte
            CTimeL        ;75    Temp Time Count Lo Byte
            CTimeH        ;76 6B Temp Time Count Hi Byte

            BytCnt        ;66 61 input byte count
            ModeData
            RSStat

            SaveWReg        ; Save Reg On INT, WREG & STATUS Regs
            SaveStatus
            temp
            TmOut0
            TmOut1
            TmOut2
                        ;96 1F 25 max regs
            ENDC
    tunes
    Super Member
    • Total Posts : 194
    • Reward points : 0
    • Joined: 2013/05/12 20:12:11
    • Location: 0
    • Status: offline
    Re:I am trying to understand some code that was written by an individual who passed away 2013/05/17 03:21:12 (permalink)
    0
    It's difficult to guess what is happening from just those snippets.  I think maybe you need to show more code - including the interrupt handling.  Is it some type of flag to ensure that Run_A is called once after waking from sleep?
     
    DarioG
    Allmächtig.
    • Total Posts : 54081
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: Oesterreich
    • Status: offline
    Re:I am trying to understand some code that was written by an individual who passed away 2013/05/17 04:38:14 (permalink)
    0
    Yeah, so it's not a hardware pin... it's probably a flag set somewhere...

    GENOVA :D :D ! GODO
    Guest
    Quick Reply: (Open Full Version)
      Enter the random characters shown
    Submit Post
    Some restrictions apply to prevent link (URL) Spam.
    URLs in messages, signatures, and PM's are removed unless you have ...
    • been a member for at least 0 day(s);
    • made a total of 0 post(s);
    • earned at least 0 point(s) for post scores (based on the ratings on your posts);
    • earned at least 0 reward point(s);
    Jump to:
    © 2020 APG vNext Commercial Version 4.5