Syntax:
PWMOn 'or PWMOff
Command Availability:
This command is only available on the Atmel AVR microcontrollers with a Timer/Counter0 OC0B register.
Explanation:
The PWMOn command will only enable the output of the OC0B/PWM module of the Atmel AVR microcontroller.
This command is not available for any other OCnx/PWM modules.
This command sets up the hardware PWM module of the Atmel AVR microcontroller to generate a PWM waveform of the given frequency and duty cycle. Once PWMON method is called, the PWM will be emitted until PWMOff is called.
These constants are required for PWMOn.
Constant Name | Controls | Default Value |
---|---|---|
|
Specifies the output frequency of the PWM module in KHz. |
38 |
|
Sets the duty cycle of the PWM module output. Given as percentage. |
50 |
Example:
'This program demonstrates the PWMOn and PWMOff commands 'of the fixed mode HPWM on OC0B pin. #chip mega328p,16 'activate appropriate PWM output pins dir PortD.5 Out 'OC0B 'define PWM_Freq in kHz 'define PWM_Duty in % #define PWM_Freq 40 #define PWM_Duty 50 do 'turn on/off single channel 40 KHz PWM on OC0B pin PWMON wait 5 s PWMOFF wait 5 s loop
For more help, see PWMOn and PWMOff or, for Microchip microcontrollers see Fixed Mode PWM for Microchip