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.

Which pin should I connect pwm output to in pic18f452?

Status
Not open for further replies.

s13v3n

Junior Member level 1
Joined
Jul 24, 2007
Messages
17
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,396
i have a pwm output and want to connect to a pic microcontroler.which pin should i connet to?
 

pic18f452 pwm on port

if u r using PIC BASIC compiler or proton plus compiler u can connect it to any pin
 

pwm pic18f452

i am using 18f452 PIC microcontroller
 

pwm com pic18f452

i want to measure the speed of the vehicle.so i need to use the pwm output to measure the distance travel and from the distance obtain i want to calculate the speed of the car.
 

pwm pin for pic18f452

then you can give it to any of the port pin,
try avoiding portA. Port B should be the best
 

18f452 pwn

do u know anywhere i can get some example of source code?
 

Re: pwm to pic18f452

Hi,
Here is a sample code:
Code:
//Program to generate 40kHz output at RC2(CCP1) pin
//Microcontroller: Microchip PIC18452
//Language: C
//Compiler: mikroC v8.20
//Programmer: Tahmid

void main (void){
     TRISC = 0;
     PORTC = 0;
     ADCON1 = 7;
     T2CON = 0;
     TMR2 = 0;
     PWM1_Init(40000); //40kHz
//The value in brackets in PMW1_Init represents the frequency in Hz
     PWM1_Change_Duty(128); //50% duty cycle
// Choose Duty cycle as such:
// PWM_Change_Duty(x);
// x = ( (Duty Cycle in %) / 100) * 255
     PWM1_Start(); //Start PWM
     while (1){ //Loop forever
// Whatever else might be needed to be done while PWM is running
     }
}
 

Re: pwm pic18f452

i am using 18f452 PIC microcontroller

If you want to use hardware PWM then you can use RC1 (CCP2) or RC2 ( CCP1) as PWM output, but you can get the same frequency (PWM) output if you use both

-Yavar
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top