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.

Problem with the PIC 16F877A

Status
Not open for further replies.

mohsin_ee08

Newbie level 6
Joined
Jan 31, 2012
Messages
14
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,372
I'm working on a project using PIC 16f877A.
The circuit works fine in Proteus but PIC doesn't get "ON" while implemented on hardware. Enable and chip select are connected as required! Pins 11, 12, 31 and 32 are also appropriately connected.

Can someone please detect the problem and share a solution ??
 

Problem may be with the configuration bits...

Check the configuration bits or Post your code here.
 

THE CODE IS GIVEN BELOW. AS I'VE MENTIONED, IT WORKS FINE IN PROTEUS BUT NOT ON HARDWARE! PLEASE SUGGEST A SOLUTION!


// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;

sbit LED at RB7_bit;

sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections

char txt3[]="W";
char txt4[]="";

double peaki, nowi, nowv, peakv, peakw;
int i=0;

void main(){
ADCON1= 6;
TRISA=0xFF; //portA as input
ADCON1 = 0x00; // Select Verf and Right Justify
ADCON1 = 0B11001001; // Select Analog1 RC_Mode and ADON
PORTB=0;
TRISB=0; //output

Lcd_Init(); // Initialize LCD

Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1,13, txt3);
LED=1;

peaki=0;
peakv=0;
nowi=1;
nowv=1;
while(1){
while (i<100) {
i++;
nowi=ADC_Read(0);
nowi=nowi*5/1024;
nowi=nowi-2.4948;

if(nowi<0.001)
nowi=0;
if(nowi>peaki)
peaki=nowi;

nowv=ADC_Read(1);
nowv=nowv*5/1024;
nowv=nowv-2.4948;

if(nowv<0.001)
nowv=0;
if(nowv>peakv)
peakv=nowv;
}
i=0;

peakw=peaki*peakv;
peakw=peakw/2;
FloatToStr(peakw, txt4);
Lcd_Out(1, 1, txt4);
LED=~LED;
}

}
 

which is your compiler ? Which is your programmer ?

It will not work in real hardware if you didn't configured the configuration bits. In PIC16F877A, just try it with 0x3f3A. Either you could give the configuration bits in the C program or you could give it at the time of burning. In most programmer software, there will be an option to set the configuration bits. This word is programmed at address 0x2007 of PIC16F877A. To know more about the configuration bits, check the PIC16F877A data sheet.
 
Last edited:

i don't remember it... but after programming, the device verifies and states that the code is burned correctly.
 

If it verifies correctly, it doesn't means it contains the configuration bits.

How you are loading the hex to PIC ? Is it some thing like winpic ? or which one ?

Any way I don't know if the mikroC already include configuration bits by default or not...
But I think you can see it on the programmer and you can edit it etc... So atleast try to see what is the configuration bits ...
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top