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.

[PIC] PWM USING PIC 16f887

Status
Not open for further replies.

incognito007

Newbie level 3
Joined
Mar 26, 2014
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
18
Code:
/*
   Frequency 8Mhz
 */
 
 
void main()
{    
     PORTC=0;    //Clearing output port
     TRISC=0x00; //Initialising C port as output
     T2CON=0;    //Prescaler for timer (1:1) Timer2 off
     CCP1CON=12;  //Initialising ADC
     TMR2ON_BIT=1; // Turning On timer 2
      PR2=199;     //  Setting Time period/Frequency
     CCPR1L=80;  //  Setting Duty Cycle
}

Will this code generate 10 MHz
 
Last edited by a moderator:

First thing your oscillator frequency is only 8 MHz, How can you generate 10 MHz
 

    V

    Points: 2
    Helpful Answer Positive Rating
[
/*
Crystal Frequency 8Mhz

*/


Code:
void main()
{
     PORTC=0;    //Clearing output port

     TRISC=0x00; //Initialising C port as output

     T2CON=0;    //Prescaler for timer (1:1) Timer2 off

     CCP1CON=12;  //Initialising ADC

     TMR2ON_BIT=1; // Turning On timer 2

      PR2=199;     //  Setting Time period/Frequency

      while(1)
      {
        CCPR1L=99;  //  Setting Duty Cycle

      }
]
SORRY I want frequency of 10 KHz.This code is working in PROTEUS.
My question is ,when I remove the while loop and write CCPR1L=99; outside, the code is not working.
Why is it so
 

hello,


i didn't check your code, but you must have an infinite loop at the end of you code
else program stop..

Code:
void main()
{
     PORTC=0;    //Clearing output port

     TRISC=0x00; //Initialising C port as output

     T2CON=0;    //Prescaler for timer (1:1) Timer2 off

     CCP1CON=12;  //Initialising ADC

     TMR2ON_BIT=1; // Turning On timer 2

      PR2=199;     //  Setting Time period/Frequency

  
        CCPR1L=99;  //  Setting Duty Cycle

         while(1);
      }
 

Yes that for loop is loading the CCPR1L register infinitely.
Is it required to load the CCPR1L register with duty cycle bit every time a pulse is produced.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top