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.

Helps on P18f2520(PWM) urgent..

Status
Not open for further replies.

Questions

Newbie level 3
Joined
Jul 28, 2010
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Singapore
Activity points
1,312
Helps on P18f2520(PWM)

Hi all. I am new here.I would like to ask why my PWM program does not work. FYI, i am using MPLAB, ICD2 complier and crystal oscillator is 8Mhz. Here my code:

#include<p18f2520.h>
#include<delays.h>

void main(){

TRISC=0b11011111; // RC5 as output
T2CON=0b00000111; //prescaler=16
CCP1CON=0b00011100;

while(1){

PR2=0b01111100; //1Khz
CCPR1L=0b00111110;
Delay100TCYx(200);
Delay100TCYx(200);
Delay100TCYx(200);


PR2=0b00011000; //5Khz
CCPR1L=0b00001100;
Delay100TCYx(200);
Delay100TCYx(200);
Delay100TCYx(200);


}
}


I hope some kind souls can help me with this code.Tell me what goes wrong and where is the problem.

Thanks in advance.--- God bless you.
 

.

what configuration have you used for the pic?

Added after 19 minutes:

wait a minute the the CCP1 output is RC2 which you have set as input.

TRISC=0b11011011; // RC5 and RC2 as output

and it works perfectly
 

    Questions

    Points: 2
    Helpful Answer Positive Rating
Thanks a lot..I will try now..

Added after 52 minutes:

Thanks...it works.

Do you have any idea on how to initialize a 8 bits serial port LCD(LASCAR sp5-gfx1)?
 

I am glad it works, This lcd that you mentioned uses SPI, if you search for it you will get many examples. some other graphic LCD's also use it. the best advise is to check the datasheet for this LCD
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top