SPWM and Elapsed Timer


Closed Thread
Results 1 to 13 of 13

Hybrid View

  1. #1

    Default SPWM and Elapsed Timer

    Is it possible to run these two beasts together since they both use TMR1?

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    You could change the Elapsed Timer to a different timer fairly easily.

    SPWM should stay on Timer1, because it needs a 16-bit timer, and is harder to modify.
    <br>
    DT

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Darrel,

    What files would need to be modified? Just the Elapsed_INT.bas? Would you be able to help with the ASM part of it as it is for the most part greek to me. Oh yeah, the PIC I'm using it the 16F88 @ 10 MHz.

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Elapsed Timer for TMR2

    Quote Originally Posted by CocaColaKid View Post
    Would you be able to help with the ASM part of it as it is for the most part greek to me.
    That's too bad....
    ASM is the Best part of Picbasic Pro.

    Learning one without the other is like buying a space shuttle without the solid rocket boosters.
    It looks nice, but it's not going to take you where you want to go. <hr>
    Ok, here ya go.

    The Elapsed Timer for use with Timer 2.

    Code:
    <font color="#0000FF"><b><i>; Initialze your hardware and LCD first
    
    </i></b></font><font color="#008000"><b>INCLUDE </b></font><font color="#FF0000">&quot;DT_INTS-14.bas&quot;     </font><font color="#0000FF"><b><i>' Required
    </i></b></font><font color="#008000"><b>INCLUDE </b></font><font color="#FF0000">&quot;Elapsed-T2.bas&quot;     </font><font color="#0000FF"><b><i>' Elapsed Timer for TMR2
    
    </i></b></font><font color="#008000"><b>ASM
    </b></font><font color="#000080">INT_LIST  macro    </font><font color="#0000FF"><b><i>; IntSource,        Label,  Type, ResetFlag?
            </i></b></font><font color="#000080">INT_Handler   TMR2_INT,  _ClockCount,   ASM,  yes
        endm
        INT_CREATE               </font><font color="#0000FF"><b><i>; Creates the interrupt processor
    
        </i></b></font><font color="#000080">INT_ENABLE  TMR2_INT      </font><font color="#0000FF"><b><i>; Enable TMR2 Interrupts  
    </i></b></font><font color="#008000"><b>ENDASM
    
    GOSUB </b></font><b>ResetTime
    </b><font color="#008000"><b>GOSUB </b></font><b>StartTimer
    
    Main</b>:
        <font color="#008000"><b>IF </b></font><b>SecondsChanged </b>= <font color="#800000"><b>1 </b></font><font color="#008000"><b>THEN
           LCDOUT </b></font><font color="#800000"><b>$FE</b></font>,<font color="#800000"><b>2</b></font>, <font color="#008000"><b>DEC </b></font><b>Days</b>,<font color="#FF0000">&quot;d-&quot;</font>,<font color="#008000"><b>DEC2 </b></font><b>Hours</b>,<font color="#FF0000">&quot;:&quot;</font>,<font color="#008000"><b>DEC2 </b></font><b>Minutes</b>,<font color="#FF0000">&quot;:&quot;</font>,<font color="#008000"><b>DEC2 </b></font><b>Seconds
           SecondsChanged </b>= <font color="#800000"><b>0
        </b></font><font color="#008000"><b>ENDIF
    GOTO </b></font><b>Main</b>
    Attached Files Attached Files
    DT

  5. #5


    Did you find this post helpful? Yes | No

    Default

    Oh thank you very much. Now I have to compare the two and see exactly what is different and figure out why.

    I know I have to learn ASM as it is the foundation on which PBP is built. It's just a lot harder to understand for us noobies.

  6. #6


    Did you find this post helpful? Yes | No

    Default

    Darrel,

    Is there a better way to output a 82Hz PWM single than using your software routine. Your routine works perfect however I also need to read a frequency of 0-1kHz at the same time. With the resolution of 256 steps @ 82Hz its pretty interrupt hungry.

    Here's what I'm trying to accomplish

    TMR1 is being used for SPWM - 0-24VDC @ 82Hz
    TMR2 is being used for HPWM - 0-10VDC

    If I use the COUNT command it works perfect, only if I disable the interrupts though. This in turn kills the SPWM which I can't have happen. Any suggestions? Not looking for a hand out by any means, just some help pointing in the right direction. The best way to learn is do it yourself I believe.

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