This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

还是关于TImerA的PWM

guide里写:

111 Reset/Set 

The output is reset when the timer counts to the TACCRx value. It is set when the timer

counts to the TACCR0 value.

 

那么对于需要调节占空比的PWM,当调节到TACCRx=TACCR0时到底是什么情况呢?100%占空比能实现么?

 

 

另外,内部的EQUx的时序是怎样的?

  • 产生100%占空比要看是哪种模式:

    1、上升模式:TACCRx >= TACCR0+1

    2、上升下降模式:TACCRx >= TACCR0

    EQUx 是哪个由比较值大小来决定产生的先后

  •  

    还是不太明白

     

    那个框图不用贴了吧?

     

     输出模式 7    PWM 复位/置位模式: 

    输出电平在 TAR 的值等于 TACCRx 时复位, 

    当 TAR 的值等于 TACCR0 时置位。

     

     

    到底是个什么时序呢?

     

  • 这个图只是一个示意图,TACCR0、TACCR1、TACCR2都会产生对应的EQUx事件

  • 谢谢楼上回答

    不过手册上就是这样写的:

    输出模式 7    PWM 复位/置位模式:

    输出电平在 TAR 的值等于 TACCRx 时复位,

    当 TAR 的值等于 TACCR0 时置位。

    既然有点不一样就像您写的:1、上升模式:TACCRx >= TACCR0+1

    为什么不稍微详细说明白一点呢?

  • 比较值大于周期值,让比较一直不能发生,达到周期值TACCR0之后会一直保持高电平,这是可靠的100%占空比产生方法

    若是TACCRx = TACCR0,我不能保证是先复位还是先置位,需要做实验核实下。

  • 那么还有TACCRx=0的时候会是什么情况呢?

  • 那就只有一个定时器CLOCK的高电平时间

  • 不明白,我问的是如果TACCRx=0,占空比是0还是大于0(一个分辨率?)呢?

  • 还是迷惑

     

    HARDY ZHOU说:

     

    比较值大于周期值,让比较一直不能发生,达到周期值TACCR0之后会一直保持高电平,这是可靠的100%占空比产生方法

    若是TACCRx = TACCR0,我不能保证是先复位还是先置位,需要做实验核实下。

     

     

    既然TACCRx = TACCR0不一定保险,那么在官网的一个文档:PWM DC Motor Control Using Timer A of the MSP430 

    中,好像TACCRx可以等于0或者等于TACCR0,并没有到TACCR0+1呀

    文档中代码如下:

     

    #include          "msp430x11x1.h" ; Standard Equations

     

    NAME  DCmotorspeedcontroller

    ;******************************************************************************

    ;    

    ;    Murugavel Raju

    ;    Texas Instruments, Inc

    ;    

    ;******************************************************************************

    ;CPU registers used

    ;******************************************************************************

     

    #define    Duty_cycle   R6                

     

    ;******************************************************************************

    ;Constants

    ;******************************************************************************

    PWM_OUT    equ    004h                    ; bit2 of Port1 / TA1  

    Period     equ    0ffh                    ; Counts for D/A, 8bits = 256 

    ;******************************************************************************

    ;

    ;******************************************************************************

               RSEG  CSTACK

               DS    0           

    ;****************************************************************************** 

               RSEG CODE

    ;****************************************************************************** 

     

    RESET      mov     #SFE(CSTACK),SP         ; define stackpointer

               call    #Init_Sys               ; Initialize            

     

    Mainloop   bit.b   #BIT0,&P2IN             ; check if 'decrease' button pressed      

               jz      Next1

     

               bit.b   #BIT1,&P2IN             ; check if 'increase' button pressed

               jz      Next2

     

               jmp     Mainloop                ; loop if no button pressed 

     

    Next1      cmp     #0,Duty_cycle           ; check if PWM = 0

               jz      Mainloop                ; repeat loop

               dec     Duty_cycle              ; increment the PWM by one step           

               jmp     SendPWM         

     

    Next2      cmp     #0ffh,Duty_cycle        ; check if 256 steps are done

               jz      Mainloop                ; Repeat for next cycle

               inc     Duty_cycle              ; increment the PWM by one step

     

    SendPWM    mov     Duty_cycle,&CCR1        ; Send value to PWM output

               call    #Delay                  ; insert a small delay between key polling

               jmp     Mainloop                ; repeat loop

     

    ;******************************************************************************

    Init_Sys;  Modules and Controls Registers set-up subroutine

    ;******************************************************************************

    StopWDT    mov     #WDTPW+WDTHOLD,&WDTCTL  ; Stop Watchdog Timer

     

    SetupBC    mov.b   #XTOFF+RSEL2+RSEL1+RSEL0,&BCSCTL1   

                                               ; RSEL=7

               mov.b   #0ffh,&DCOCTL           ; DCO selected for highest freq.                                            

     

    SetupP1    mov.b   #0,&P1OUT               ; P1OUT reset

               bis.b   #PWM_OUT,&P1SEL         ; P1.2/TA1 for PWM OUT                

               bis.b   #0ffh,P1DIR             ; P1.2 output for PWM OUT and remaining unused

     

    SetupP2    mov.b   #03ch,&P2DIR            ; P2.0,P2.1 as inputs,P2.2 to P2.5 outputs(unused) 

     

               mov     #Period,&CCR0           ; Set Period length for PWM output  

               mov     #0,&CCR1                ; Initial PWM value for output

               mov     #OUTMOD_7,&CCTL1        ; Set output mode 7 for TA1

    SetupTA    mov     #TASSEL1+MC0,&TACTL     ; Set TimerA Up mode, SMCLK as TACLK

     

               mov     #0,Duty_cycle           ; reset Duty_cycle buffer

               ret                             ; Return from subroutine

     

     

    ;******************************************************************************

    Delay;     Software delay

    ;******************************************************************************

               push    #03FFFh                 ; Delay to TOS

    L1         dec     0(SP)                   ; Decrement TOS

               jnz     L1                      ; Delay over?

               incd    SP                      ; Clean TOS

               ret                             ; Return from subroutine

     

     

    ;****************************************************************************** 

                 COMMON  INTVEC                 ; MSP430F1xx Interrupt vectors             

    ;******************************************************************************               

                 ORG     RESET_VECTOR

    RESET_VEC    DW      RESET                  ; POR, ext. Reset, Watchdog

     

                 END

     

  • 虽然我很懒也没精力,要忙忙这个又要忙忙那个,还是想着什么时候写两句验证一下的,尽管要把lauchpad上原有的东西拔下来。

    不过我看了这个帖子:PWM -- what is special about 0% and 100% duty-cycle?  后又懒得弄了,弄了也可能和那个帖子的人一样呀。

    哪位给解释解释呀

  • 你好!

    如Hardy Zhou所述,0% 100%是可以实现的,令可以参考下面帖子进行实验:

    www.deyisupport.com/.../8169.aspx