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.

PIC16F877A With mplab htc problem

Status
Not open for further replies.

RDxGladi

Newbie level 3
Joined
Feb 9, 2013
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,311
Hi everyone i'm new to this forum i have searched desperately everywhere for a solution but i just cannot get the pic to work :roll::roll::roll::roll: i wrote a code first which was rather big but once i burned it i couldnt get any output out of pic but than i wrote a simple programe which just toggled PORTB of the PIC uC and again i couldnt get the pic to work i even hooked it up with a voltmeter to check if i can get any output at any portB pin but nothing. Well than someone suggested that i should burn the hex code than try to read and and compare the two so i did. but the code i burned and read were different now i have no idea what should my next approach be i have searched everywhere desperately for help i have a final year project on pic and i even cant get the damn thing to work please please any help will be greatly appreciated btw im using mplab ide v 8.87


this is my simple code

#include<pic.h>
#include<htc.h>
//#include <htc.h>
//#include <xc.h>
//#FUSES HS
#define data PORTB
#define FOSC=4Mhz
#define _XTAL_FREQ 4e6 // 4MHz
#ifndef _XTAL_FREQ
#define _XTAL_FREQ 4MHZ /* Crystal frequency in MHz */
#endif
#define XTAL 4000000
#define RS RD0
#define EN RD1
#define PB PORTB;
__CONFIG(HS & WDTDIS & PWRTEN & BORDIS & LVPDIS);
void delay_ms(int x)
{
int i,j;
for(i=0;i<165;i++){
for(j=0;j<x;j++){
}
}
}
void main()
{
TRISB=0x00;
while(1){
PORTB=0x00;
delay_ms(100);
PORTB=0xFF;
delay_ms(100);
}
}
 

Hi,

Well you have three areas that could be faulty, program code, programming into the chip and your hardware circuit.

I don't do C but it looks basically ok, though I would increase the delay to ms(1000) otherwise your voltmeter will not show an on /off swing.

Would also be good to see your hardware circuit to check for things like Mclre Pin1 pulled up to +5v etc

Seems your first problem is the programming of the chip, what programmer /software are you using, most will automatically verify a chip anyway and pass or fail accordingly, a step you do not mention, though your own read seems to be wrong - just one byte or a lot of code ?

Again how are you connecting your chip to the programmer , stand alone or in the user circuit ?
 

Hi,
Thank you for such a fast reply about your questions I have tried increasing the delay with no avail, and yes y mclr pin is pulled high to 5valso there is no fault in the programmer as other students use it too the programmer does not show any error wille burning the code but when I read it only one byte or so mismatches from original
 

Hi,
Thank you for such a fast reply about your questions I have tried increasing the delay with no avail, and yes y mclr pin is pulled high to 5valso there is no fault in the programmer as other students use it too the programmer does not show any error wille burning the code but when I read it only one byte or so mismatches from original

Hi,

Try proving your system with this code which flashes PortB every 4 seconds. (876A and 877A the same for the purpose of this test)

As you can see from the jpegs the programmed code is read back the same.
 

Attachments

  • 4secflash.7z
    154.9 KB · Views: 31

HI
I did try to increase the delay i now increased it all the way to delay_ms(4000) still no output i have tried burning your code directly to my pic the programmer shows no error but there is no output Frankly I'm running out of ideas now :/
 

Hi,

So you burnt my 4 second flashing code into the chip and you could read it back as the same, but nothing works.

Sound then as if your circuit is at fault.

Is it on a breadboard ?
Can you show a picture of it.
Can you at least show a diagram of it.
You might have damaged the chip, have you tried another one ?

All typical beginner problems - don't be too frustrated...
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top