Desperately seeking Help. PIC18F242 Resets!

Coding and general discussion relating to the compiler

Moderators: David Barker, Jerry Messina

Post Reply
Francesco.C
Posts: 41
Joined: Thu Feb 26, 2009 6:54 pm
Location: UK

Desperately seeking Help. PIC18F242 Resets!

Post by Francesco.C » Fri May 21, 2010 6:57 pm

Hello guys,

please take a look at this simple code
----------------------------------------------
Device = 18F242
Clock = 4.0
WDT(OFF)

Output (PORTA.0)
High(PORTA.0)
---------------------------------------------

I am getting a regular square wave output.
This is a mistery to me.

I have tryed everything I can think-of.
I have read the datasheet, but Ihave found no reasons why I get
a square wave from pin A0 (I have tryed others pins).

It seems to me that the PIC is resetting all the time

I have already fitted a new PIC with no success!

Am I missing something really basic?

Thank you in advance.

Francesco
:(

Doj
Posts: 362
Joined: Wed Apr 11, 2007 10:18 pm
Location: East Sussex

Post by Doj » Fri May 21, 2010 11:38 pm

It looks like there is nothing to keep the code in order, try a while-wend after the statements so the code has something to do after it has set the pins.

Also, the HIGH statement will make the pin an output regardless of its previous state(low on an input).

Francesco.C
Posts: 41
Joined: Thu Feb 26, 2009 6:54 pm
Location: UK

Post by Francesco.C » Sat May 22, 2010 7:07 am

I missed the 'while - wend' from the post, butt it is already there.

Any more ideas?

Francesco

Francis
Registered User
Registered User
Posts: 314
Joined: Sun Mar 25, 2007 9:40 am
Location: Devon

Post by Francis » Sat May 22, 2010 8:03 am

I haven't the same PIC, but your code worked on a 4620 fine.
No restarts. LED came on and stayed on.
Do you have any 'unpleasant' loads on that pin? (Or any pin?)
Is your MCLR pin pulled high?
Is your PSU OK or some noisy sw/mode?

What happens if you put a delay before high?

Jon Chandler
Registered User
Registered User
Posts: 185
Joined: Mon Mar 10, 2008 8:20 am
Location: Seattle, WA USA
Contact:

Post by Jon Chandler » Sat May 22, 2010 9:46 am

Do you have 0.1 uF bypass caps on the power supply pins? Is /MCLR pulled high with a 10k resistor?

Francesco.C
Posts: 41
Joined: Thu Feb 26, 2009 6:54 pm
Location: UK

Post by Francesco.C » Sat May 22, 2010 1:17 pm

Thank you for the advice guys.

Yes I got a pullup on the MCLR pin......but, I discovered that it was not soldered very well. It was floating. :oops:

I can get-on now with my project now.

Thanks a lot.

Regards

Francesco

Post Reply