SPWM_INT - Multiple Software PWM Question


Results 1 to 20 of 20

Threaded View

  1. #10


    Did you find this post helpful? Yes | No

    Default Re: SPWM_INT - Multiple Software PWM Question

    Any idea why I get this ASM warning when compiling my code? I've included the snippet of code which I think is applicable, and the full code too.

    Name:  ASM_Warning.png
Views: 875
Size:  16.7 KB

    Code:
    ' ***************************************************************
    ' Set up registers for PWM on CCP3 & 4
    ' ***************************************************************
    
    ; Use Mister E's MultiCalc to calculate PR2 value & hence Prescaler setting
    ; for T2CON:
    
    ; http://www.picbasic.co.uk/forum/content.php?r=159-New-PIC-Utility.-PICMultiCalc
    
    ; Can also use this web-based site:
    ; http://www.micro-examples.com/public/microex-navig/doc/097-pwm-calculator.html
    
    CCP3CON = %00001100         ; Use CCP3 in PWM mode
    CCP4CON = %00001100         ; Use CCP4 in PWM mode
    
    ;CCPTMRS = %00000000         ; Use Timer2 for all CCPs in PWM mode
                                 ; (The default appears to be Timer2, so no need
                                 ; to set it explicitly)
                                 
    T2CON   = %00000100         ; Timer2 on with 1:1 prescaler
    PR2     = 249               ; For 16Mhz OSC the desired output of 16,000Hz is
                                ; achieved with this PR2 value (10-bit resolution
                                ; with 1:1 prescaler)
    
    MinDuty CON 50              ; Lowest possible duty cycle at which motor spins
    MaxDuty CON 1000            ; Maximum duty cycle available with PR2 = 249 and
                                ; 1:1 prescaler (According to Darrel:
                                ;      MaxDuty = (PR2 + 1) * 4
    
    DutyVar3 VAR WORD
    DutyVar4 VAR WORD
    
    ' Spin up motors to saved value of _MotorRPM
    ' (Below a cycle of MinDuty, the motors don't move at all)
    FOR I = (MinDuty - 10) to MotorRPM
        DutyVar3  = I
        CCP3CON.4 = DutyVar3.0
        CCP3CON.5 = DutyVar3.1
        CCPR3L    = DutyVar3 >> 2
    
        IF PortEngDir = 0 THEN
            DutyVar4  = I
            CCP4CON.4 = DutyVar4.0
            CCP4CON.5 = DutyVar4.1
            CCPR4L    = DutyVar4 >> 2    
        ELSE
            DutyVar4  = (MaxDuty - I)
            CCP4CON.4 = DutyVar4.0
            CCP4CON.5 = DutyVar4.1
            CCPR4L    = DutyVar4 >> 2        
        ENDIF
    
        pause 33
    NEXT I
    Full PIC code:
    PIC16F1825_Code.txt
    Last edited by RossWaddell; - 20th January 2013 at 22:54.

Similar Threads

  1. Darrel's Multiple Software PWM
    By passion1 in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 15th October 2013, 15:21
  2. Replies: 1
    Last Post: - 4th March 2013, 21:57
  3. DT Multiple Software PWM and 18F2321 issue
    By microuser in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 20th December 2012, 08:23
  4. General Question About Multiple Interrupts
    By grzeh666 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 31st August 2008, 17:09
  5. Multiple HPWM question
    By Johan in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 17th October 2007, 13:00

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