![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
PrinceNai
Joined: 31 Oct 2016 Posts: 463 Location: Montenegro
|
18f4520 MCLR |
Posted: Wed Apr 17, 2019 12:25 pm |
|
|
Hi,
I have a battery powered project using 18f4520. The battery voltage is 4,25V, charger is connected all the time. My "problem" is that it works perfectly with Pickit3 connected in debug mode, but fails to start if I disable fuses for debugger and run it in production mode. But not every time, sometimes it does start. I tried configurations with crystal and internal oscillator, it behaves the same. The resistor on MCLR is 10k, I get correct voltages on that pin. 4,25V with the switch open and 0V when I press the reset button. If I put 5k resistor on MCLR, it starts let's say 70% of the time. If I short MCLR directly to battery voltage it starts every time. What would be the lowest safe resistor value on MCLR?
Right now I disabled MCLR and use another switch to cause interrupt and reset the CPU in code, but that is not the solution I like.
This is the header for my project:
Code: |
#include <18F4520.h>
#device PASS_STRINGS = IN_RAM //copy all the strings to RAM to allow access with pointers
#device adc=10 //10 bit AD resolution
//#device ICD=TRUE
//#FUSES DEBUG //No Watch Dog Timer
//#include <stdlib.h>
#FUSES WDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
//#FUSES HS //High speed Osc, high power 16MHz-25MHz
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES PUT
#FUSES INTRC
//#FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES NOMCLR
//#use delay(crystal=20000000) //20Mhz clock
#use delay(internal=32000000)
//#use rs232(baud=115200,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=GSM,errors)
#use rs232(parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=GSM,errors)
#use i2c(Master,slow,sda=PIN_C4,scl=PIN_C3, force_hw)
//#use i2c(Master,slow,sda=PIN_C4,scl=PIN_C3)
//#use pwm(output=pin_c2, timer=2, frequency=1kHz, duty=3)
//#use pwm(output=pin_a4, output=pin_b3, timer=1, frequency=1 kHz, duty=75, disable_level=low)
|
Regards |
|
![](templates/subSilver/images/spacer.gif) |
dluu13
Joined: 28 Sep 2018 Posts: 395 Location: Toronto, ON
|
|
Posted: Wed Apr 17, 2019 12:57 pm |
|
|
I can't seem to find this in your datasheet but in the PIC24 that I use, there is this part at the beginning showing how to hook up /MCLR. At least for my chip, 10K is within spec.
So I have the normally open reset button in parallel with the transistor.
how are your power hookups? Do you have all of your capacitors? |
|
![](templates/subSilver/images/spacer.gif) |
PrinceNai
Joined: 31 Oct 2016 Posts: 463 Location: Montenegro
|
|
Posted: Wed Apr 17, 2019 1:32 pm |
|
|
I have two caps from Vdd to Vss, less than 10mm from the pins. No cap on reset pin. I read the datasheet, also errata. Nothing is mentioned there. I'm thinking voltage is the problem, because I missed the part that I actually need an LF part for my supply. I just saw 2 - 5,5V part, had a bunch of them lying around. I am old, 20 years ago 5V was the only standard. Now we have 5V chips, 3,3V chips, 3,7V batteries, 4,2V batteries :-) |
|
![](templates/subSilver/images/spacer.gif) |
dluu13
Joined: 28 Sep 2018 Posts: 395 Location: Toronto, ON
|
|
Posted: Wed Apr 17, 2019 1:44 pm |
|
|
Ah, I misread and thought your battery was 4.5V. I didn't mention anything since the datasheet says the chip should function with supply down to 4.2V. I guess what you can try is to hook up 5V from a bench supply or USB and see what happens :D |
|
![](templates/subSilver/images/spacer.gif) |
PrinceNai
Joined: 31 Oct 2016 Posts: 463 Location: Montenegro
|
|
Posted: Wed Apr 17, 2019 2:22 pm |
|
|
4,27V when fully charged. But it works without a glitch down to 3,2V with MCLR OFF, talks with an A6 GSM module at that voltage, sends out SMS-s. It just doesn't obey MCLR reset and doesn't start if reset pin is enabled. |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9177 Location: Greensville,Ontario
|
|
Posted: Wed Apr 17, 2019 4:54 pm |
|
|
OK, first 4.2v is just on the lower edge of being operational. Just because that part works doesn't guarantee it WILL work 100%, next week when it gets hotter or colder. A cold battery will have far less capacity. An 'L' version is what I recommend for ALL battery operated devices. You mention some kind of 'GSM' device. They typically take a LOT of power for a short time and can easily drop VDD to below 4.2, another bad situation.
Page 43 of the datasheet ,show a 'typical' *MCLR wiring. I'd use a 1K pullup, 1K series and a .1 cap AND the DIODE. You've found out going from 10K to 5K helped, so try the 1K. You can't hurt the PIC by trying, heck you can hardwire it to VDD...
re: old ?? heck you're only 'old' if you remember when you had to erase PICs in a UV chamber for 15 minutes... it was a great excuse for LOTS of coffee breaks !
Jay |
|
![](templates/subSilver/images/spacer.gif) |
PrinceNai
Joined: 31 Oct 2016 Posts: 463 Location: Montenegro
|
|
Posted: Wed Apr 17, 2019 7:47 pm |
|
|
Quote: |
re: old ?? heck you're only 'old' if you remember when you had to erase PICs in a UV chamber for 15 minutes... it was a great excuse for LOTS of coffee breaks !
|
Well, I do. Pushing 50, and the way things are going with electronics, a year older and behind every day. Today kids are doing things with Chinese ARM-s that are 10 times faster and 4 times cheaper than any Pic. Or Arduino, which I just can't digest. No IDE to speak of, but tons of code that just works.
But I went on a strange tangent right now :-). I'll try with a lower resistance or stick with a coded reset. The project in question is an alarm that sends SMS messages around, shuts down the stove and turns on a few ventilators. It is a must that only a manual reset clears any abnormal condition. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19378
|
|
Posted: Wed Apr 17, 2019 11:24 pm |
|
|
Thing is that I'm assuming this is something like a LiPo cell attached to a
charger?. Now 4.25v is pushing the maximum that such a cell can be
charged to. Then the fact the battery is there, implies that you presumably
do want the unit to be able to work when there is no charge power?.
Unless your voltage detection is connecting to exactly the same point
as the PIC, it doesn't take much for the PIC to be getting a fraction of
a volt less than you are measuring, at least momentarily.
It does sound as if the chip is 'borderline' on not being able to work.
Things generally get more fussy when you get near to the 'limits' of
a chip.
Have you got brownout enabled?. What is the voltage set to?.
Look carefully at the margins for the voltage on this. Is it possible
that your voltage is actually inside the range. It'd need to be set to
the 2.79v nominal level to allow reliable operation at your level.
Brownout should be used on any system where there may be issues
with the rise time of the supply, or the supply is marginal, which
yours is.... It's worth noting that the higher brownout voltages
designed for the 'F' chip, have a 'low' point of just 4.33v nominal,
which shows that the manufacturer doesn't really rate the chip to
reliably operate down at 4.25v. ![Sad](images/smiles/icon_sad.gif) |
|
![](templates/subSilver/images/spacer.gif) |
PrinceNai
Joined: 31 Oct 2016 Posts: 463 Location: Montenegro
|
|
Posted: Thu Apr 18, 2019 10:54 am |
|
|
LF :-).
Thank you all. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19378
|
|
Posted: Thu Apr 18, 2019 12:08 pm |
|
|
Good.
It is one of the very annoying 'features' of the data sheets for chips
with two different voltage versions. Causes a lot of grief... |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|