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.

Help Needed For PIC16f877a Clock Problem

Status
Not open for further replies.

hardyboy_86

Junior Member level 2
Joined
Apr 13, 2011
Messages
21
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,433
I am using 16f877a , but problem is that it is not generating Clock,, i have changed many crystals (20MHZ) but no result,, i have checked the crystal frequency ( it was showing 193 KHZ) ,I have programmed it in C and have used NOWDT , and HS Mode in fuses, also i have programmed in PIC C Compiler and burnt it in University Lab Programmer,, i have connected pic in its minimum configuration and used Pull-Up resistor with MCLR,, I have noticed that 193 KHZ Frequency is remain present at the pin 13 and 14 instead when no crystal was connected to it..
and Pulsating 1.3V is present at all ports.
Please Help!!

I am Programing a line follower Robot, and My Program is

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include <16F877a.h>
#device adc=8
#fuses NOWDT,HS,NOPROTECT,NOLVP
#use Delay(clock=20000000)
#include <C:\Users\Faizan\Desktop\Autonomous Line Following Robot\Program\ROBO WORKSHOP\LCD DRIVER FILE.c>
float v0,v1,v2,v3,v4;
void rightside()
{
set_PWM1_duty(180);
setup_timer_2(T2_div_by_16,127,1);
 
set_PWM2_duty(0);
setup_timer_2(T2_div_by_16,127,1);
}
 
void leftside()
{
set_PWM1_duty(0);
setup_timer_2(T2_div_by_16,127,1);
 
set_PWM2_duty(180);
setup_timer_2(T2_div_by_16,127,1);
}
 
void straight()
{
set_PWM1_duty(180);
setup_timer_2(T2_div_by_16,127,1);
 
set_PWM2_duty(180);
setup_timer_2(T2_div_by_16,127,1);
}
//-----------------------------------------------------------------
void main(void)
{
setup_ccp1(CCP_PWM);
setup_ccp2(CCP_PWM);
setup_adc_ports(ALL_ANALOG);
setup_adc(ADC_CLOCK_INTERNAL);
lcd_init();
lcd_gotoxy(1,1);
printf(lcd_putc,"START");
while(1)
{
//--------------Right Side------------------------------
set_adc_channel(1);
delay_us(5);
v1=read_adc();
v1=v1/51;
if(v1<2 & v2>2 & v3>2 )
{
rightside();
lcd_gotoxy(1,1);
printf(lcd_putc,"RIGHT SIDE");
}
//-------------------STRAIGHT----------------------------
set_adc_channel(2);
delay_us(5);
v2=read_adc();
v2=v2/51;
if(v1>2 & v2<2 & v3>2 )
{
straight();
lcd_gotoxy(1,1);
printf(lcd_putc,"STRAIGHT");
}
//-----------------LeftSide--------------------------------
set_adc_channel(3);
delay_us(5);
v3=read_adc();
v3=v3/51;
if(v1>2 & v2>2 & v3<2 )
{
leftside();
lcd_gotoxy(1,1);
printf(lcd_putc,"LEFTSIDE");
}
 
}
 
}

 
Last edited by a moderator:

Can you provide a schematic for your circuit? One thing I've seen people miss in the past are the ~20pF caps on each lead of the crystal. Table 14-2 says for a 20 MHz XTAL in HS mode, you need two 15-33 pF caps. See Figure 14-1 for wiring diagram.

https://ww1.microchip.com/downloads/en/devicedoc/39582b.pdf
 

Yes I Have Connected 20 pf Capacitor on each pin of (Pin 13 and Pin 14)
 

#include <C:\Users\Faizan\Desktop\Autonomous Line Following Robot\Program\ROBO WORKSHOP\LCD DRIVER FILE.c>

Another thing, Are you sure, your compiler is not complaining for the above line?
 

Yes Compiler Successfully Compiled my Program, No Errors found
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top