Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Delay For PWM Signal generated using PIC16f877A

Status
Not open for further replies.

sudhinpk

Junior Member level 1
Joined
Jan 27, 2014
Messages
18
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
105
I am generating PWM Signal for my project using CCP module of PIC16F877A. Now I need to generate one signal with 20us dealay than other. How can I code it? My program for PWM Generation is given below


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
void main() {
 TRISC.F2 = 0;  //CCP1 (RC2) Pin as Output
 T2CON = 0X00;
 T2CON.T2CKPS1 = 0;  // Prescalar = 1:4
 T2CON.T2CKPS0 = 1;
 PR2 = 0x7C; // PWM Period = 20kHz  //PR2 = ( ( PWM Period) / ( Tosc x 4 x Prescaler ) ) - 1
 CCPR1L = 0X32;  // On Time, when Duty Cycle = 70%
 CCP1CON.CCP1X = 0; // (CCPRxL:CCPxCON<5:4>) = (Duty Cycle*Period)/(Tosc*(Prescalar))
 CCP1CON.CCP1Y = 0;
 CCP1CON = 0X0F;  // PWM Mode
 T2CON.TMR2ON = 1;
 while(1);
}

 
Last edited by a moderator:

not clear in what you asked but from my understating:
If you need two PWM signals refer:
HTML:
https://www.edaboard.com/threads/279062/
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top