Minor Microcontroller Problem

Thread Starter

Skyferia

Joined May 5, 2010
20
Hi,

Alright here's the deal. I have a PIC16F877A microcontroller which somewhat refuses to work. Here's the details:

  • Programmed PIC16F877A using MPLAB and PICKIT2 to open ports A, B and D
  • Tested with an LED (with a 100Ω resistor in series), does not light up
  • Measured from a(ny) pin of Ports A, B and D to ground but has practically no reading
  • Measured from VDD to VSS, obtained 5V reading
  • Components untouched, reprogrammed PIC - noticed a short flicker on the LED when in process of programming
I've tried the PIC on both my development kit and breadboard but with same results. From your experiences, is my PIC busted or is there something I overlooked?

I do not have (access to) another PIC for the moment unfortunately.


= EDIT =
Forgot the code. Here:
Rich (BB code):
#include <pic.h>

__CONFIG(0x3f3A);                // 20Mhz HS XTAL-OSC

void main(void)
{
        TRISA = 0x00;
        TRISB = 0x00;
        TRISD = 0x00;
        ADCON = 0x06;
        CMCON = 0x07;
        PORTA = 0xFF;
        PORTB = 0xFF;
        PORTD = 0xFF;

        while(1)
        {
        for(int i=0;i<20000;i++)
        {
            PORTA = 0xFF;
            PORTB = 0xFF;
            PORTD = 0xFF;
         }
    }
}
 
Last edited:

t06afre

Joined May 11, 2009
5,934
If you can program your device and verify the programmed data. I think it is good change for that your PIC is working.
It is often wise to start very simple. Start with port A only. Then add some LEDS to PORTA. Also remember to set the ADCON1 register. It should have value 0x06h to set AN7 to AN0 as digital pins. If you have not done it, download the data sheet, and crosscheck what you have done for every register used
 

Thread Starter

Skyferia

Joined May 5, 2010
20
If you can program your device and verify the programmed data.
Yes I can program and verify the data.

I think it is good change for that your PIC is working.
I'm sorry, I don't quite get what you mean.

It is often wise to start very simple. Start with port A only. Then add some LEDS to PORTA. Also remember to set the ADCON1 register. It should have value 0x06h to set AN7 to AN0 as digital pins. If you have not done it, download the data sheet, and crosscheck what you have done for every register used
Well.. Port B does not have any "restrictions" and can be readily programmed by only setting the tri-states as output. Will try the method you mentioned and update once done.

Thank you kindly.

= EDIT =
Updated the code with
Rich (BB code):
ADCON1 = 0x06;
and... no, still not working... sigh, this'll teach me to always have a spare around.
 
Last edited:

t06afre

Joined May 11, 2009
5,934
You could try to implement with RC oscillator. It could be that your oscillator is not working. Place the R and C component close the IC
 

Thread Starter

Skyferia

Joined May 5, 2010
20
You could try to implement with RC oscillator. It could be that your oscillator is not working. Place the R and C component close the IC
I did, and they are close to the IC. I even replaced the crystal with a 4MHz oscillator and two 15pF capacitors (and changing the config to __CONFIG(0x3f39)), still same results.

The strange thing is the LED flicker during the time of programming. When I place the LED at, say, Port D, there was no flicker whatsoever.
 

t06afre

Joined May 11, 2009
5,934
Are you sure the programmer is not pulling the MCLR low. I think it is low by default then using PICKIT 2. You have to pull it high in MPLAB.
 

Thread Starter

Skyferia

Joined May 5, 2010
20
Are you sure the programmer is not pulling the MCLR low. I think it is low by default then using PICKIT 2. You have to pull it high in MPLAB.
Really? Hmm.. could you guide me on how I can pull it high in MPLAB?

= EDIT =
It's alright I got it! Thanks guys, truly appreciate the help.
 
Last edited:

t06afre

Joined May 11, 2009
5,934
That's weird and kinda odd. Don't use MPLAB, but use PICkit 2 in stand alone mode, so never had a problem with MCLR before.
You can use the PICKIT 2 application to control the MCLR pin also. But then this option is not selected. The MCLR pin is released to be controlled by the Hardware not the PICKIT. This is not the case in MPLAB. I think in the PICKIT application they turn the line controlling the MLCR into an input then not used to pull the line low
 

reema paul

Joined Jun 28, 2010
12
start with board checking move on to open single port and then all.thou dint get y u use adcon1 where u just hv to switch on ports.
use
*********SOP********
include<htc.h>
void main()
{
unsigned int i;
TRISB=0X00;
TRISC=0X00;
TRISD=0X00;
PORTB=0XFF;
for(i=0;i<=0x0f;i++);
PORTC=0XFF;
for(i=0;i<=0x0f;i++);
PORTD=0XFF;
for(i=0;i<=0x0f;i++);
}
*****************EOP***********
try using this...still if there is no output.then ur controller is busted!
all d best
 
Top