CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Problem when PIC power on!!!
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
tienchuan



Joined: 25 Aug 2009
Posts: 175

View user's profile Send private message Yahoo Messenger

Problem when PIC power on!!!
PostPosted: Sun Jun 01, 2014 8:59 pm     Reply with quote

Hi all.
I've a problem when PIC power on. In my circuit, i've used large capacitor (0.022F-5.5V) to built in power backup for PIC, for using save data in eeprom when lost main power.
Here's schematic of circuit:
https://docs.google.com/file/d/0Bz215_lkn4g-cXlvSHFjX2RwVnM/edit
I used to Brownout Reset function at 2.8V to reset PIC, but when I power on, PIC is not run.
I used PIC18F4680, CCS C complier ver 5.021.
My config fuses code:
Code:
#fuses H4,PUT,NOPROTECT,NODEBUG,NOLVP,NOWDT,NOPBADEN,MCLR,BROWNOUT,BORV28,STVREN 

Please show me a ways to fix it.
Thanks all.
_________________
Begin Begin Begin !!!
dyeatman



Joined: 06 Sep 2003
Posts: 1939
Location: Norman, OK

View user's profile Send private message

PostPosted: Sun Jun 01, 2014 9:07 pm     Reply with quote

Please show your crystal frequency line and tell us what crystal part
number, frequency and value of caps you are using.

Are you running the PIC at 5V?
_________________
Google and Forum Search are some of your best tools!!!!
tienchuan



Joined: 25 Aug 2009
Posts: 175

View user's profile Send private message Yahoo Messenger

PostPosted: Sun Jun 01, 2014 9:19 pm     Reply with quote

Thanks u.
I'm running PIC at 4.4V ( VCC-> diode-> VCC-PIC), VCC:5.2V from adapter.
I'm using crystal 10MHZ, 2pin, dip type and no part, 2 caps 22 p.
My schematic of PIC:
https://drive.google.com/file/d/0Bz215_lkn4g-NGNNSlhVZVpNUmM/edit?usp=sharing
And my code config:
Code:

#include <18F4680_me.h>                                                                                                                                                                             
#fuses H4,PUT,NOPROTECT,NODEBUG,NOLVP,NOWDT,NOPBADEN,MCLR,STVREN,BROWNOUT,BORV21
#use delay(clock=40000000)                                                                                                     
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, errors)   // HARD UART       

Thanks for u help !!!
_________________
Begin Begin Begin !!!
dyeatman



Joined: 06 Sep 2003
Posts: 1939
Location: Norman, OK

View user's profile Send private message

PostPosted: Sun Jun 01, 2014 9:37 pm     Reply with quote

Crystal hookup looks ok on the surface.

You are running awful close to minimum (4.2). Your meter error may be
that much. What happens if you apply a full 5V?

Also try using HS instead of H4 and set the use_delay to 10Mhz to see what
happens. It may be the PLL wont fire up at that low a voltage.
_________________
Google and Forum Search are some of your best tools!!!!
tienchuan



Joined: 25 Aug 2009
Posts: 175

View user's profile Send private message Yahoo Messenger

PostPosted: Sun Jun 01, 2014 9:49 pm     Reply with quote

I've tried with setup oscillator 10MHZ with HS fuses, but it still don't work:|
Have another problems ?
_________________
Begin Begin Begin !!!
dyeatman



Joined: 06 Sep 2003
Posts: 1939
Location: Norman, OK

View user's profile Send private message

PostPosted: Sun Jun 01, 2014 10:09 pm     Reply with quote

Try HS/10Mhz at 5V with just these fuses
INTRC, NOLVP, NOWDT, MCLR

I left out PUT because I have seen it cause startup issues.

If this doesn't work I suspect something other than the program.
_________________
Google and Forum Search are some of your best tools!!!!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jun 02, 2014 12:30 am     Reply with quote

Read Ttelmah's comments in these threads about saving eeprom
during power-down of the PIC:
http://www.ccsinfo.com/forum/viewtopic.php?t=44144
http://www.ccsinfo.com/forum/viewtopic.php?t=38936
Ttelmah



Joined: 11 Mar 2010
Posts: 19569

View user's profile Send private message

PostPosted: Mon Jun 02, 2014 12:43 am     Reply with quote

Key is that you need to build your own MCLR circuit to actually hold the PIC in reset until the supply has properly stabilised.

On some PIC data sheets you will find there is a maximum time specified for the supply to get to the working voltage, for the internal reset to work. All PIC's actually have this limit, but only some 'tell you' about this. If a supply rises too slowly, the POR is not generated, and often the oscillator hasn't started, and the kick needed to start this doesn't happen.
If you look (for instance) at the data sheet for the PIC18F4620, you have a section for 'power on reset', and the comment:
"External Power-on Reset circuit is required
only if the VDD power-up slope is too slow.
The diode D helps discharge the capacitor
quickly when VDD powers down."
They then specify that the supply must rise at a minimum of 0.05V/msec, for the internal MCLR to be used. So no more than 100mSec to 5v.

On many crystals/PIC's, adding a large resistor (perhaps 1MR) across the crystal, will ensure it starts. Then if you add an external MCLR circuit, to hold the MCLR low for slightly longer than the time needed for your supply to reach it's operating voltage (remember to have the diode across the pullup resistor on this to avoid damaging the PIC), then gets everything to work.

As a comment though, have you actually calculated how much capacitance you need to keep the PIC running to write the data (simple discharge calculation based upon the current drawn by the PIC)?. Generally a capacitor of only a few uF is enough to power a PIC to write a dozen or more bytes to EEPROM. You may be creating your own problem by going rather too far.

Generally PUT, should always be used with a crystal, and shouldn't cause any problems. It'll only cause problems where your external circuitry requires lines to be operated as soon as the PIC boots, and in these cases PUT should be removed, but then your code should, before anything involving 'timing' is done, use the status bit to check that the oscillator is stable before proceeding. Otherwise quite a few things will 'time' incorrectly for the first few mSec after boot. That is what PUT is there to stop. It is not normally wanted or needed with INTRC.

As a further comment, you say that you are using HS, and 10MHz, then show fuses for INTRC (which can't do 10MHz).

I see PCM_programmer has posted pointing to some earlier threads about power up problems, while I was typing). Smile
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Mon Jun 02, 2014 5:13 am     Reply with quote

Code:
#include <18F4680_me.h>
This suggests you have modified the include file as supplied by CCS. Never do this!!! The values in the header file might change in the next release and then your program might fail with you wasting lots of time to figure out the problem.
If you didn't change the file and have your own local copy of the header file, then use "..." instead of <...>
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Mon Jun 02, 2014 8:23 am     Reply with quote

Quote:

Generally a capacitor of only a few uF is enough to power a PIC


i have done this task by using a 5V supply through a low drop schottky diode to the PIC power pin , bypassed with up to 220uf/10v of tantalum cap to ground
as a storage buffer and been able to reliably write 16 bytes to eeprom.
your amount of Capacitance - particularly if back feed FROM the storage cap to other circuits on board --
IF that is not blocked - can be a problem.
ALSO
if you pic is sourcing significant current drive current from any pin at power down time ( like driving a LED even ) - all bets are off.

EDIT: if forgot to add --the first thing your power down handler should do is
change all your I/O's to INPUTS...
tienchuan



Joined: 25 Aug 2009
Posts: 175

View user's profile Send private message Yahoo Messenger

PostPosted: Sat Jun 07, 2014 9:06 am     Reply with quote

Thanks you Ttelmah.
A few day, I tested again board but result not achieved, the circuit sometimes run corect, not stop when power star.
I think I have a problem with large capacitor and algorthim to save data when power loss.
I searched on forum and saw your topic discussion about how choosing buffer capacitor. And I saw this equation to calculates the value of buffer capacitor.
C= I*t/(delta)V
In my case, when power loss, the HLVD interrupt is trigged, and it perform task read 2 byte address, and write 6 byte data, final, write 2 byte new adress again. So that, i need 5*10=50ms to save data in external EEPROM, ensure i choose time equal 60ms, I caculate that I needed 1000uF buffer capacitor (i=10mA, t= 60ms, delta V = 4.62-4=0.6V).
Follow your idead,I think before I choose large capacitor because i dont using right osscilator when power loss, i need to switch osscilator to minimum to save more power for writing in eeprom. Can you show me find a way to switch and choose right osscilator?
About the reset circuit, I only use resistor pull up because i read a manual of pickit3, so i careless about it, i 'll checked it again.
Thanks
About the reset circuit, pr


I tried with your suggest, adding 1MR resistor parallel with crystal, but it
_________________
Begin Begin Begin !!!
tienchuan



Joined: 25 Aug 2009
Posts: 175

View user's profile Send private message Yahoo Messenger

PostPosted: Sat Jun 07, 2014 9:10 am     Reply with quote

ckielstra wrote:
Code:
#include <18F4680_me.h>
This suggests you have modified the include file as supplied by CCS. Never do this!!! The values in the header file might change in the next release and then your program might fail with you wasting lots of time to figure out the problem.
If you didn't change the file and have your own local copy of the header file, then use "..." instead of <...>

Thanks you:)
I don't change inside 18F4680.c supply by CCS, I only copy to my folder project and rename it.
Thanks.
_________________
Begin Begin Begin !!!
tienchuan



Joined: 25 Aug 2009
Posts: 175

View user's profile Send private message Yahoo Messenger

PostPosted: Sat Jun 07, 2014 9:13 am     Reply with quote

asmboy wrote:
Quote:

Generally a capacitor of only a few uF is enough to power a PIC


i have done this task by using a 5V supply through a low drop schottky diode to the PIC power pin , bypassed with up to 220uf/10v of tantalum cap to ground
as a storage buffer and been able to reliably write 16 bytes to eeprom.
your amount of Capacitance - particularly if back feed FROM the storage cap to other circuits on board --
IF that is not blocked - can be a problem.
ALSO
if you pic is sourcing significant current drive current from any pin at power down time ( like driving a LED even ) - all bets are off.

EDIT: if forgot to add --the first thing your power down handler should do is
change all your I/O's to INPUTS...

Thanks you.
I'll replace diode by schottky diode, I want PIC run near 5v power.
Can you send me a code of schottky diode in your circuit.
Thanks
_________________
Begin Begin Begin !!!
Ttelmah



Joined: 11 Mar 2010
Posts: 19569

View user's profile Send private message

PostPosted: Sat Jun 07, 2014 12:22 pm     Reply with quote

If your calculation says '1000uF', then why use 22000uF?.

The EEPROM takes 4mSec/byte, not 10mSec/byte, so your calculated value is already 2.5* larger than needed, you are running with at least 50* the capacitance needed....
Big problem is that the capacitor make take an age to fully discharge. Once the voltage on it drops below the point where the PIC oscillator stops, consumption plummets, so the chip may well be sitting with a couple of volts still on the capacitor, several minutes after you switch 'off'.
tienchuan



Joined: 25 Aug 2009
Posts: 175

View user's profile Send private message Yahoo Messenger

PostPosted: Tue Jun 10, 2014 7:04 pm     Reply with quote

Ttelmah wrote:
If your calculation says '1000uF', then why use 22000uF?.

The EEPROM takes 4mSec/byte, not 10mSec/byte, so your calculated value is already 2.5* larger than needed, you are running with at least 50* the capacitance needed....
Big problem is that the capacitor make take an age to fully discharge. Once the voltage on it drops below the point where the PIC oscillator stops, consumption plummets, so the chip may well be sitting with a couple of volts still on the capacitor, several minutes after you switch 'off'.

Thanks for your reply.
In my circuit, I choose large capacitor because when i done with test board, I put parallel 10 capacitor(1000UF/16V) to backup power for PIC, so that I choose large capacitor because it's smaller. But this is terrible, as you told it bigger than right value.
I think my trouble is not switching oscillator to low frequency when detected power loss. In my main program, I run PIC with 40MHZ (PLL),so that should i switch to right frequency to power loss? 32 KHz, is that right or another value?
Pls show me way to monitor oscillator to enough for PIC run right?
Thanks u.
_________________
Begin Begin Begin !!!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group