



































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Microcontroller is a best subject to learn. Feel free to explore them.
Typology: Lecture notes
Uploaded on 06/24/2020
1 / 43
This page cannot be seen from the preview
Don't miss anything!




































2
4 Another example, common in practice, is the use of PWM signals in the circuit for generating signals of arbitrary waveforms such as sinusoidal waveform. See figure below:
5 A typical example is a power control circuit. Refer to figure below. ◦ If a logic zero ( 0 ) indicates the switch-off and a logic one ( 1 ) indicates the switch-on, the electrical power that load consumers will be directly proportional to the pulse duration. ◦ This ratio is often called Duty Cycle.
Example of duty cycle; Pulse time = 50 μs Period = 200 μs Duty cycle = 50 / 200 * 100 = 25 % Pulse time = 50μs
Period = 200 μs
Amplitude = 5 Volts Period = 200 μs Pulse time = 50 μs
TRISC = 0b
13 PIC16F877A microcontroller has two independent CCP(Capture/Compare/PWM) modules, named as CCP1 and CCP2. Each CCP module has two 8-bit resistors(CCPxH,CCPxL) that can be use as: 16 bit Capture Register 16 bit Compare Register 10 - bit PWM Register. PWM frequency is limited from the PR 2 (Timer 2 module has an 8 - bit period register) register value. PR 2 value is limited from 0 to 255 only.
16 For 20MHz oscillator frequency: From above table, you can know available PWM frequency from Prescaler value. You should decide PR2 value and prescaler value at this point.
17 As example, please calculate PR2 value for the following table shows how to generate PWM signals of varying frequency if the microcontroller uses 20MHz quartz-crystal.
19 Let say for PWM frequency=2kHz, Prescale = 16, OSC frequency = 20MHz: TO CALCULATE IN CLASS!!!! IMPORTANT
20 Example (ONLY USE 8BIT CCPR1L)