📄 pwm.s
字号:
;**********************************************
;**************Pulse Width Modulator***********
;**********************************************
PWM_CTRL0 EQU 0x40b00000 ;//PWM Control Registers 0
PRESCALE00 EQU (0x0<<0)
PRESCALE01 EQU (0x0<<1) ;PWMn Prescale Divisor.
PRESCALE02 EQU (0x0<<2) ;Determines the frequency of the PWM module clock (in terms of the 3.86 MHz clock)
PRESCALE03 EQU (0x0<<3) ;PSCLK_PWMn = 3.6864 MHz / (PWM_CTRL[PRESCALE] + 1)
PRESCALE04 EQU (0x0<<4)
PRESCALE05 EQU (0x0<<5)
PWM_SD0 EQU (0x0<<6) ;if pwm_sd=0x0 Graceful shutdown. if pwm_sd=0x1 Abrupt shutdown
PWM_CTRL0_Value EQU (PRESCALE00|PRESCALE01|PRESCALE02|PRESCALE03|PRESCALE04|PRESCALE05|PWM_SD0)
PWM_DUTY0 EQU 0x40b00004 ;//PWM Duty Cycle Registers0
DCYCLE00 EQU (0x0<<0)
DCYCLE01 EQU (0x0<<1) ;
DCYCLE02 EQU (0x0<<2)
DCYCLE03 EQU (0x0<<3)
DCYCLE04 EQU (0x0<<4)
DCYCLE05 EQU (0x0<<5)
DCYCLE06 EQU (0x0<<6)
DCYCLE07 EQU (0x0<<7)
DCYCLE08 EQU (0x0<<8)
DCYCLE09 EQU (0x0<<9)
FDCYCLE0 EQU (0x0<<10) ;fdcycle=0 PWM clock (PWM_OUTn) duty cycle is determined by DCYCLE field.fdcycle=1 PWM_OUTn is set high and does not toggle.
PWM_DUTY0_Value EQU (DCYCLE00|DCYCLE01|DCYCLE02|DCYCLE03|DCYCLE04|DCYCLE05|DCYCLE06|DCYCLE07|DCYCLE08|DCYCLE09|FDCYCLE0)
PWM_PERVAL0 EQU 0x40b00008 ;//PWM Period Control Register0
PV00 EQU (0x0<<0)
PV01 EQU (0x0<<1)
PV02 EQU (0x0<<2)
PV03 EQU (0x0<<3)
PV04 EQU (0x0<<4)
PV05 EQU (0x0<<5)
PV06 EQU (0x0<<6)
PV07 EQU (0x0<<7)
PV08 EQU (0x0<<8)
PV09 EQU (0x0<<9)
PWM_PERVAL0_Value EQU (PV00|PV01|PV02|PV03|PV04|PV05|PV06|PV07|PV08|PV09)
PWM_CTRL1 EQU 0x40c00000 ;//PWM Control Registers 1
PRESCALE10 EQU (0x0<<0)
PRESCALE11 EQU (0x0<<1) ;PWMn Prescale Divisor.
PRESCALE12 EQU (0x0<<2) ;Determines the frequency of the PWM module clock (in terms of the 3.86 MHz clock)
PRESCALE13 EQU (0x0<<3) ;PSCLK_PWMn = 3.6864 MHz / (PWM_CTRL[PRESCALE] + 1)
PRESCALE14 EQU (0x0<<4)
PRESCALE15 EQU (0x0<<5)
PWM_SD1 EQU (0x0<<6) ;if pwm_sd=0x0 Graceful shutdown. if pwm_sd=0x1 Abrupt shutdown
PWM_CTRL1_Value EQU (PRESCALE10|PRESCALE11|PRESCALE12|PRESCALE13|PRESCALE14|PRESCALE15|PWM_SD1)
PWM_DUTY1 EQU 0x40c00004 ;//PWM Duty Cycle Registers 1
DCYCLE10 EQU (0x0<<0)
DCYCLE11 EQU (0x0<<1) ;
DCYCLE12 EQU (0x0<<2)
DCYCLE13 EQU (0x0<<3)
DCYCLE14 EQU (0x0<<4)
DCYCLE15 EQU (0x0<<5)
DCYCLE16 EQU (0x0<<6)
DCYCLE17 EQU (0x0<<7)
DCYCLE18 EQU (0x0<<8)
DCYCLE19 EQU (0x0<<9)
FDCYCLE1 EQU (0x0<<10) ;fdcycle=0 PWM clock (PWM_OUTn) duty cycle is determined by DCYCLE field.fdcycle=1 PWM_OUTn is set high and does not toggle.
PWM_DUTY1_Value EQU (DCYCLE10|DCYCLE11|DCYCLE12|DCYCLE13|DCYCLE14|DCYCLE15|DCYCLE16|DCYCLE17|DCYCLE18|DCYCLE19|FDCYCLE1)
PWM_PERVAL1 EQU 0x40c00008 ;//PWM Period Control Register 1
PV10 EQU (0x0<<0)
PV11 EQU (0x0<<1)
PV12 EQU (0x0<<2)
PV13 EQU (0x0<<3)
PV14 EQU (0x0<<4)
PV15 EQU (0x0<<5)
PV16 EQU (0x0<<6)
PV17 EQU (0x0<<7)
PV18 EQU (0x0<<8)
PV19 EQU (0x0<<9)
PWM_PERVAL1_Value EQU (PV10|PV11|PV12|PV13|PV14|PV15|PV16|PV17|PV18|PV19)
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -