PDA

View Full Version : PIC18F got some weird problem?



NatureTech
- 17th February 2007, 14:43
Hi everyone,

I gotta some problem with blinking my PIC18F452, which the version of PBP is 2.47 and with the latest MPASM.I changed the INC file a bit ( HS_OSC )and thats all.Is the problem could be the capacitor (0.1uf) that should be placed in the ICSP programmer(I use EPIC) which is near the header or some other thing.Below is the code :

(BACK TO BASIC)

Define OSC 16

TRISA = %00000000
TRISB = %00000000
TRISC = %00000000
TRISD = %00000000
TRISE = %00000000



Led_1 var PORTB.0
Led_2 var PORTB.1


low Led_1
low led_2



start:


high led_1
pause 500
low led_1


goto start


and the INC file:

;************************************************* ***************
;* 18F452.INC *
;* *
;* By : Leonard Zerman, Jeff Schmoyer *
;* Notice : Copyright (c) 2005 microEngineering Labs, Inc. *
;* All Rights Reserved *
;* Date : 12/16/05 *
;* Version : 2.47 *
;* Notes : *
;************************************************* ***************
NOLIST
ifdef PM_USED
LIST
"Error: PM does not support this device. Use MPASM."
NOLIST
else
LIST
LIST p = 18F452, r = dec, w = -311, w = -230, f = inhx32
INCLUDE "P18F452.INC" ; MPASM Header
__CONFIG _CONFIG1H, _OSCS_OFF_1H & _HS_OSC_1H
__CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_128_2H
__CONFIG _CONFIG4L, _LVP_OFF_4L
NOLIST
endif
LIST
EEPROM_START EQU 0F00000h
BLOCK_SIZE EQU 8
.................................................. .................................................. ....

So what could be the problem?.....

mister_e
- 17th February 2007, 16:52
there's one line missing...


high led_1
pause 500
low led_1
pause 500

goto start

NatureTech
- 17th February 2007, 16:54
Thanks a lot steve,doh!!..i tried i many times but sometimes get rush!!

But steve,sometimes it doesn't work?.

mister_e
- 17th February 2007, 17:03
When you say sometime it doesn't work... what do you refer to?
programming or the blink?

make sure you have set the EPIC software to program the config fuses. I know there's an option somewhere.

when you program it, make sure you (or the programmer) tie/load the PGM pin to gnd.

and the usual, Both VSS and VDD connected, 0.1 uF close to the PIC, MCLR to Vdd.

No loose connection between the PIC and the crystal+Caps. And short distance between the PIC and the crystal.

NatureTech
- 17th February 2007, 17:06
I also found that it resets itself.Could it be the perfboard problem?.

I just made SPI work between 2 PIC ( 18F452 & 18F458 ).It worked but sometimes,it resets and return to main loop although i had set BOR to lowest and make PWT enable + placed 2 npo 7 multilayer ceramic and 2 tantalum cap as near as possible to PIC.The Vreg uses LDO with good quiecent current which i belive would handle load very well.So why sometimes it resets itself?

NatureTech
- 17th February 2007, 17:15
The software part.It sometimes reset itself.I face no problem programming it as i do play with the fuses cuz sometimes you need to activate PLL and so on.So no problem with programming.Everything is ok.But,i face no idea why it don't want to for example:blink a led every 1 second..it's no "go".Maybe i spent so much time on CCS...hehehe...

mister_e
- 17th February 2007, 17:17
Without the whole code and schematic it's hard to say...
Stack-Overflow reset?
Faulty MCLR contact?
BAD config fuses programming (LVP_ON could do some strange thing sometimes)
messy supply line may cause some BOD reset as well
etc etc etc

To me scoping the VDD rail to see if it's clean and monitor the MCLR pin would be my first test...

Well, you could still use CCS to see if the results are the same ;) It have to be!

NatureTech
- 17th February 2007, 17:24
So,you belive this problem nothing to do with the EPIC programmer nor the software,that would be PBP version 2.47.My first thought is that the problem might come from the EPIC programmer as it was stated in the melabs website recommending a 0.1 uf cap between the power line?.Is that really neccessary?.I don't face any problem with the programming.So it's 50-50 in my mind.

Actually , i made this circuit in perf board(donut board) or point-to-point soldering board with 16mhz crystal and a 4.7k pull-up for mclr.That's all.

mister_e
- 17th February 2007, 17:29
it's not a PBP problem.. it's working here on an EasyPIC 4 board.

Is this a EPIC problem.. maybe, i don't have it. And yup the Cap while programming should help. And yup always plae one close to your PIC and, at least, close to all other IC. I always place a 10uF tantalum close to the PIC too.

Which capacitor value did you use around your crystal?

NatureTech
- 17th February 2007, 17:33
I use 22pf npo 7 grade cap.Mmm..it's fine..

Hey,you mentioned about the stack overflow right.Mmmm..Does that always come in a way to this sort of problem.I don't think so.I always set LVP off as this is not the "J" type PIC.

mister_e
- 17th February 2007, 17:42
F... weird. Did you also erase the PIC before programming it?

Once programmed, read it back, and look the config fuses haven't change to something else.

There's some days like that...

Did you also tried to program your PIC in circuit?


I always set LVP off as this is not the "J" type PIC.
Sorry but it has nothing to do with the J type... or, HEHE i misunderstood something awhile back ;)

Darrel Taylor
- 18th February 2007, 13:58
Do you leave the Epic plugged into the board.

With mine, if I turn on a fluorescent light nearby, it'll reset the PIC.
If it's unplugged, it doesn't happen. But normally I just leave it plugged in and ignore the resets.

Also had a screen saver that does something to the parallel port when it activates. It resets the pic too. Stopped using that screen saver.
<br>

mister_e
- 18th February 2007, 14:02
I already heard some strange stuff... but a screen saver that poll the parallel port :eek:

So their XP printer polling PATCH didn't solved the problem?

NatureTech
- 19th February 2007, 16:18
Hey yo steve and darrel,

It's working.I add some config on the inc file (STACK OVERFLOW & LVP OFF)(and that's weird too why that thing come in my way?) and it's working.So do goes for the SPI.It never jump to main loop this time.Thanks a lot guys.I safely blinked the LED'S this time.Talk about screen saver polling LPT's,geee..that's freaky.Lucky for me,i disable screen savers as i hate one =>.But the flourescent,is that for real?.Cuz i do work or test anything i do with my only one table lamp thats couple of inches away from my project desk.I don't face that kind of problem and especially 'resets' on pic?.Hmm..for sake i gotta bear in my mind.But i face a 50hz distortion ( using fluke dmm) but i knew that's a AC current nearby but i do re-calculate.Beside,the nature of flourecent driver (balast ,starter e.t.c) is more toward crude stuff.