Download Lecture Notes
Transcript
56 PWM Library CCP module is available with a number of PICmicros. mikroC provides library which simplifies using PWM HW Module. Note: Certain PICmicros with two or more CCP modules, such as P18F8520, require you to specify the module you want to use. Simply append the number 1 or 2 to a Pwm. For example, Pwm2_Start(); Also, for the sake of backward compabitility with previous compiler versions and easier code management, MCU's with multiple PWM modules have PWM library which is identical to PWM1 (i.e. you can use PWM_Init() instead of PWM1_Init () to initialize CCP1). Library Routines Pwm_Init Pwm_Change_Duty Pwm_Start Pwm_Stop Pwm_Init Prototype void Pwm_Init(unsigned long freq); Returns Nothing. Description Initializes the PWM module with duty ratio 0. Parameter freq is a desired PWM frequency in Hz (refer to device data sheet for correct values in respect with Fosc). This routine needs to be called before using other functions from PWM Library. Requires MCU must have CCP module. Example Initialize PWM module at 5KHz: Pwm_Init(5000); Pwm_Change_Duty 56