Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

A very strange problem on 16F877

Status
Not open for further replies.

liupengjian

New Member
Now, I am working on a 16F877 programming project using C.
The program is something like that:
int8 i=0;
main()
{
do{

sendPollPkt(i)
i++;
delay_ms(100);
if(i==MaxPCID)
{i=0;}

}while (true)
}

On the other side, a VB program running on a PC will receive the Polling Pkt.

I load the program to the IC chip and run, it runs well, but whenever I shut down the power on the PCB, the program stops. However, when I start the program again, the sendPollPkt() starts from the last time I stops it. ie. if i=9 when shut down the circuit board's power, and then starts, the i will be 10 and continues to run.

I want to know how can the PIC can "remember" the value even though the power is down? The code should runs from the beginning right?

Thanks for any advice.
 
variables are stored in RAM, which is volatile. When power-off, its value is gone.
Perhaps the 'i' value you get is stored in the buffer of PC??
 
Thanks, but I also checked the VB side, there is no mistake in taking the Polling data, what I see from the PC side, is what it was sent out from the PIC.

I guess, Is it because the Capacitors connected to the Vdd and Vss pins of the 16F877 that give the PIC power after the external power switched off.
In that case, the capacitor remained the RAM's value, so that the program seems start to run from the last end point. Is it possible?
 
Strange non-volatile problem...

Hi there...

Possibly the serial port of the PC is supplying power to the capacitors on the circuit (through clamping diodes on I/O-pins of the PIC). The build up voltage could be enough to retain the values in RAM, but not enough to drive the oscillator of the PIC. This would then create the symptoms you are describing.

Greetings - Jan Johansen.
 
i sugest

making a reset option in your pic..

when the pc starts it send a reset to the pic..
the pic only pulls 1 port low and in that way it reset's it self..

then you have no problem..

@ all..

TKS
 
ANY voltage in an input higher than the power supply will forward bias the input protection diode and conduct current towards the power supply.

An input of 5V will raise Vdd to 4.3 volts, if the load from the PIC and anything else on your Vdd bus is small. If it's large, it will blow the protection diode and ruin your chip.

Check Vdd when you remove the board's power. Should be 0v. Input should not be applied while your chip is unpowered.
 
Status
Not open for further replies.

Latest threads

Back
Top