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.

What's the use of CCP mode and PWM mode in PIC16f877a?

Status
Not open for further replies.

dhanraj_kmr

Advanced Member level 4
Full Member level 1
Joined
Sep 23, 2008
Messages
117
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,298
Location
Chennai, INDIA
Activity points
2,174
my doubt is whats the use of CCP mode and PWM mode in this processor?
where its required? and why????

Thanx in advance
 

Re: PIC16f877a

There are many use for CCP and PWM.
Depending on your application,
you can come out with creative ideas to use them.
There is no strict rule what they should be used for.

PWM is very useful in power switching control.
Duty cycle or frequency is normally used for circuits input.

CCP is for capturing external event with your timer.
You will be able to know the time with regards to your input trigger.
Example can be a stop watch timer features.

www.siongboon.com
 
Re: PIC16f877a

dhanraj_kmr said:
my doubt is whats the use of CCP mode and PWM mode in this processor?
where its required? and why????

Thanx in advance

Both the CCP and PWM must be understood as hardware standalone modules which properly programmed can perform tasks in the same time your instructions in the firmware are executed.

One example is generating a 50% dutycycle of a KHz signal with the PWM while a 1mS real time clock is implemented in the software without any interaction between those two. The second example is using the CCP for a frequency measurement whyle a 7 seg display is multiplexed in software for the simplest display.

Hardware modules are simplifying the microcontroller operation. You need less interrupts (or no interrupts) for things which solved in pure software are requiring a lot of processing time.

PIC16F877a is a poor microcontroller compared with any ARM or DSP. However a simple microcontroller is as valuable as many hardware modules it has inside.
 
Re: PIC16f877a

thankz a lot........... pl upload some sample programes if you feel free...........
 

Re: PIC16f877a

Here is a example for your reference

/////////////////////////////////////////////////////////////////////////
//// EX_PWM.C ////
//// ////
//// This program will show how to use the built in PIC PWM. ////
//// The program takes an analog input and uses the digital ////
//// value to set the duty cycle. The frequency is set by ////
//// the user over the RS-232. ////
//// ////
//// Configure the CCS prototype card as follows: ////
//// Connect a scope to pin 3 (C2) ////
//// Connect 9 to 15 (pot) ////
//// See additional connections below. ////
//// ////
/////////////////////////////////////////////////////////////////////////


#if defined(__PCM__)
#include <16F877.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=10000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, BRGH1OK) // Jumpers: 8 to 11, 7 to 12

#elif defined(__PCH__)
#include <18F452.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=10000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, BRGH1OK) // Jumpers: 8 to 11, 7 to 12
#endif


void main() {
char selection;
byte value;


printf("\r\nFrequency:\r\n");
printf(" 1) 19.5 khz\r\n");
printf(" 2) 4.9 khz\r\n");
printf(" 3) 1.2 khz\r\n");

do {
selection=getc();
} while((selection<'1')||(selection>'3'));


setup_ccp1(CCP_PWM); // Configure CCP1 as a PWM

// The cycle time will be (1/clock)*4*t2div*(period+1)
// In this program clock=10000000 and period=127 (below)
// For the three possible selections the cycle time is:
// (1/10000000)*4*1*128 = 51.2 us or 19.5 khz
// (1/10000000)*4*4*128 = 204.8 us or 4.9 khz
// (1/10000000)*4*16*128= 819.2 us or 1.2 khz

switch(selection) {
case '1' : setup_timer_2(T2_DIV_BY_1, 127, 1);
break;
case '2' : setup_timer_2(T2_DIV_BY_4, 127, 1);
break;
case '3' : setup_timer_2(T2_DIV_BY_16, 127, 1);
break;
}



setup_port_a(ALL_ANALOG);
setup_adc(adc_clock_internal);
set_adc_channel( 0 );
printf("%c\r\n",selection);

while( TRUE ) {
value=read_adc();

printf("%2X\r",value);

set_pwm1_duty(value); // This sets the time the pulse is
// high each cycle. We use the A/D
// input to make a easy demo.
// the high time will be:
// if value is LONG INT:
// value*(1/clock)*t2div
// if value is INT:
// value*4*(1/clock)*t2div
// for example a value of 30 and t2div
// of 1 the high time is 12us
// WARNING: A value too high or low will
// prevent the output from
// changing.
}

}
 
Re: PIC16f877a

hi all!
i'm making a topic about pic 16f877a is measuring and display speed motor on lcd
but i'm newbie i don't know about pic so much . please help me writing code and circuts.
thanks a lot!
 

Re: PIC16f877a

nobody help me!!
please help me to complete this subject.
thanks a lot
 

Re: PIC16f877a

no !! this is subject i make for myself it not a homework . i want to consult if you help me.
thanks a lot



_______________________

have fun
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top