hardware issue with pic16f877a

Status
Not open for further replies.

raafia

Junior Member level 1
Joined
Dec 24, 2009
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,413
I am trying simple led blinking code on pic16f877a .Simulations are working fine on proteus but hardware is not responding.I am using mplab with hitech compiler

My code is as follows




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
#include<htc.h>
 
__CONFIG( FOSC_HS & WDTE_OFF & PWRTE_ON & CP_OFF & BOREN_ON  & LVP_OFF & CPD_OFF & WRT_OFF & DEBUG_OFF);
 
// Define LED pin
#define LED  RB0
 
 
#define _XTAL_FREQ   20000000  
 
 
void main(void)
{
    TRISB0 = 0;                // Make RB0 pin output
    LED    = 0;                // Make RB0 low
    
    while(1)
    {
        __delay_ms(500);       // Half sec delay
        LED = 0;               // LED off
        __delay_ms(500);       // Half sec delay
        LED = 1;               // LED on
    }
}

 
Last edited by a moderator:

Please post the schematic of the circuit, including details concerning the LED and clock source circuitry.

What versions of the MPLAB and Hi-Tech Compiler are you using?

How are you programming the PIC, utilizing a PICkit, ICD, etc?

After programming does the MPLAB IDE verify and indicate programming was successful?

After programming are you running the code in debug mode or releasing/resetting the device?


BigDog
 


I have attached the circuit diagram . I am using using MPLAB IDE v 8.91 and hitech9.83.I am using Dataman 48UXP universal programmer for programming the pic and that software indicates that the programming is succesful.What do you mean by running the code in debug mode ?
 

Attachments

  • led.png
    50 KB · Views: 101

are you using battery power circuit ???

place a resistor between the Vdd and MCLR (to limit the current).
 

are you using battery power circuit ???

place a resistor between the Vdd and MCLR (to limit the current).

I have tried that too placing a 10k resistor but still not working.

- - - Updated - - -

hi
check the clock circuit! are you using a crystal with 2 caps (between 15 and 22 pF)?

yeah i am using 22pf capacitors
 

hi raafia
i notice someting about your code, you declared
Code:
__CONFIG( FOSC_HS & WDTE_OFF & PWRTE_ON & CP_OFF & BOREN_ON  & LVP_OFF & CPD_OFF & WRT_OFF & DEBUG_OFF);
try to replace it by that if you are using a crystal below 4 MHZ

Code:
__CONFIG( FOSC_XT & WDTE_OFF & PWRTE_ON & CP_OFF & BOREN_ON  & LVP_OFF & CPD_OFF & WRT_OFF & DEBUG_OFF);
 

Have you put a resistor of around 330 Ohms in series with the LED. If not your LED is already dead.

- - - Updated - - -

@kgavionics

She has mentioned #define _XTAL_FREQ 20000000 . So clock is HS.

Are you testing the Circuit on breadboard?
 

Both the HS and XT oscillator settings are acceptable for a 4MHz or higher frequency crystal, I typically use the latter HS setting as most of my designs use 4MHz or higher frequencies, so that should not be the issue.

However, you have indicated the crystal frequency is 20MHz in the following line:

Code:
#define _XTAL_FREQ   20000000

Is this not correct? I cannot determine the crystal frequency from the schematic as it is too small.

You definitely need to use the pullup resistor on MCLR and 10kΩ is am appropriate value.

Another item lacking from your design is a bypass/decoupling capacitor, typically 100nF, attached as close as possible between the Vdd (5v) and Vss (GND) pins of the PIC.

You might also turn off Brown Out Detection (BOREN) as ripples on the power supply can cause the PIC to constantly reset itself or essential remain in a reset state.

Which brings me to your power supply. What is it and how well is it regulated? If it is just a common wall wart you may need to build a properly regulated PS using a 7805 and some filter caps.

What is the power quality in your locale, brown outs, outages, voltage spikes, etc, come in your locale?

Also, when you compile the code, do you have debug or release selected in the project configuration?

BigDog
 

Have you put a resistor of around 330 Ohms in series with the LED. If not your LED is already dead.

- - - Updated - - -

@kgavionics

She has mentioned #define _XTAL_FREQ 20000000 . So clock is HS.

Are you testing the Circuit on breadboard?

havn't put resistor with led, what's its significance, for limiting current or drawing current,
yes presently testing on breadboard
 



I am using 20Mhz crytal

- - - Updated - - -


i have already tried with pull up resistor but still it didnt work .I am using regulated power supply for controller.I will definitely try 100nf bypass capacitors and will let you know if there is any progress or not .
I have selected debug in project configuration .Should it be the other way round ?
 

I have selected debug in project configuration .Should it be the other way round ?

The other way around.

If you are not using an in-circuit debugger, which you've already deactivated in the configuration register settings, select "release" and recompile.

BigDog
 
Reactions: raafia

    raafia

    Points: 2
    Helpful Answer Positive Rating
The other way around.

If you are not using an in-circuit debugger, which you've already deactivated in the configuration register settings, select "release" and recompile.

BigDog
Thankyou so much ..i will check that .
Have you any experience of working on thermocouple ?

I am using K type thermocouple with ad595.The resisistance between the two terminals of thermocouple is 8k. After ad595 i am getting .25volts for room temperature and .39 volts for human body .The point is it is not giving me the stable value, a lot of variations .Can anybody please provide me with the schematic please .AD595 is fine as i have tested it as a stand alone thermometer as mentioned in data sheet.

i have tried the circuit mentioned in datasheet but that one was not working so i added some bypass capacitors in my schematic to reduce noise and it is giving me better result .
 

Attachments

  • TempBlog.JPG
    142.7 KB · Views: 93

i have tried them all , still it is not working...
did my pic blown up ??
any way to check that its fine?? it is detecting on the programmer board

- - - Updated - - -

i have tried them all , still it is not working...
did my pic blown up ??
any way to check that its fine?? it is detecting on the programmer board
 

In MPLAB IDE have you set to use Config words from Code. It might be using Config word from Project settings. If that is happening then Config in you code is not used.

Connect the LED to a different pin and try.

After ad595 i am getting .25volts for room temperature and .39 volts for human body

Amplify voltage to get 5V max for adc.
 
Last edited:

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…