View previous topic :: View next topic |
Author |
Message |
Hans Wedemeyer
Joined: 15 Sep 2003 Posts: 226
|
PIC18F4520 doing strange things |
Posted: Tue Oct 25, 2005 8:23 pm |
|
|
I hate new chips... !
This design uses the PIC18F4520 with H4 oscillator setting and a 7.372MHz crystal.
#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES H4 //High speed osc with HW enabled 4X PLL
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOBROWNOUT //No brownout reset
#FUSES BORV25 //Brownout reset at 2.5V
#FUSES PUT //Power Up Timer
#FUSES NOCPD //No EE protection
#FUSES STVREN //Stack full/underflow will cause reset
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOWRT //Program memory not write protected
#FUSES NOWRTD //Data EEPROM not write protected
#FUSES IESO //Internal External Switch Over mode enabled
#FUSES FCMEN //Fail-safe clock monitor enabled
#FUSES PBADEN //PORTB pins are configured as analog input channels on RESET
#FUSES NOWRTC //configuration not registers write protected
#FUSES NOWRTB //Boot block not write protected
#FUSES NOEBTR //Memory not protected from table reads
#FUSES NOEBTRB //Boot block not protected from table reads
#FUSES NOCPB //No Boot Block code protection
#FUSES RESERVED //Reserved
#FUSES MCLR //Master Clear pin enabled
#FUSES XINST //Extended set extension and Indexed Addressing mode enabled
#use delay(clock=29491200)
#use rs232(baud=230400,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
There is a 22K resistor from MCLR to VDD.
If the chip boots up correctly MCLR pin is very sensitive and touching it with a 10M Ohm voltmeter probe will cause a reset.
Sometimes it boots up and bypasses some code that shoudl be impossible to bypass.. I should see a total of ten flashes of an LED and it's about 50/50 chance I do.
Then sometimes the LED is just ON ! as if code has been bypassed !
void main()
{
FlashLED5Times(); // must flash 5 times
SetupPortEtc();
FlashLED5Times(); // must flash 5 times
LED_ON;
rest of code....
}
If I connect the debugger (ICDU-40) there is never a problem.
Has anyone else that strange happenings with this chip ?
Does it need a real reset generator on the MCLR ? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Oct 25, 2005 8:36 pm |
|
|
Quote: | Sometimes it boots up and bypasses some code that should be impossible to bypass |
Read this thread. It discusses two issues that might cause your problem:
A #fuses issue, and a compiler installation issue.
http://www.ccsinfo.com/forum/viewtopic.php?t=24669
On 2nd thought, I didn't see the part about it working OK with ICDU-40.
Still, change the fuse to NOXINST.
Last edited by PCM programmer on Tue Oct 25, 2005 8:38 pm; edited 1 time in total |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Tue Oct 25, 2005 8:36 pm |
|
|
I suggest checking the resistance from the MCLR pin to VDD when the power is off to ensure the 22K resistor is not open circuit. 22K is high if you do not also have a small capacitor (<=10nF) to ground on the MCLR pin. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
Hans Wedemeyer
Joined: 15 Sep 2003 Posts: 226
|
I did this.... |
Posted: Wed Oct 26, 2005 8:34 am |
|
|
PCM Programmer:
Nothing in the link that indicated a problem similar to this.
I changed to NOXINST and the lst files are intentical. The code is not doing anything fancy so I doubt it is using any of the "new" stuff anyway.
The reason I question "Does this thing need a reset generator" is if I pull the reset line low with a jumper it starts correctly every time.
asmallri:
Yes it is the classic symptom of a open circuit or broken resistor. I have already checked that! It's 22K .
Last night a wired in the recommended (data sheet) reset circuit for slow power ramp up issues and that seems to be working. This is similar to your suggestion of adding a 10nF, except the values need to be such that it creates at least 150mS delay.
I appreciate your suggetion of the 10nF was to "decouple" the pin and make it less sesitive. In fact that may work.
I have to build another board today, and I'm curious to see if the MCLR is as sensitive. If it is I'll try a 10nF first.
Why the slow ramp reset circuit fixes this issue is strange because the power ramps up very quickly. Perhaps this new generation of PIC's are more sensitive than the earlier version.
BTW I also tried NOMCLR that did not fix the issue.
Thanks for the help. |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Wed Oct 26, 2005 8:52 am |
|
|
You have the BOR reset value set low. I assume your are running this at 3.3 volts. If the chip an F or an LF part? _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
Guest
|
|
Posted: Wed Oct 26, 2005 5:12 pm |
|
|
asmallri wrote: | You have the BOR reset value set low. I assume your are running this at 3.3 volts. If the chip an F or an LF part? |
The NOBROWNOUT overides the BOR value. |
|
|
Bart
Joined: 12 Jul 2005 Posts: 49
|
|
Posted: Thu Oct 27, 2005 1:02 pm |
|
|
I had a simular problem with a change from 16F877 to 18F4550.
Finaly it was due to the MAX232 ic witch was used for the rs232 communications. The uncoupling condensator/capasitor of 100n was to less to remove the noise generated by the switching circuit from the max232. I placed some uF (10 or 22) in parallel and problem was solved. _________________ I like Skype (www.skype.com), my username is BplotM |
|
|
|