# Solving an intermittent 18F2431 PIC problem

#### camerart

Joined Feb 25, 2013
2,600
Hi,

An intermittent PIC problem has returned

3x 18F2431 Programmed using Pickit2 and 3, with added voltage supply. I've read two different PICs using MPLAB and compare the HEX files, the same.

They were programmed using an adapted socket which GNDs PIN 28 (PGM).

PIC1: Works most times, and once started works fine. I noticed that the PIC is not on the adapted socket, so all free pins are floating. There is a LED toggle to show that the PIC has initialised. If the PIC doesn't initialise, I can touch pin 28 (Or the circuit reset button) and it initialises. If I put the PIC on the adapted socket it doesn't work. If I don't use a socket it works. If I set up all free PORTB PINs to 0 (including PIN28) it doesn't work.

PIC2 and 3: Don't work under any conditions. They work otherwise.

I checked the circuit board for tracking between the PINS/TRACKS ok, and a motor for continuity of tracks, where I could.

Any ides of the likely problem welcome please.

Camerart.

Last edited:

#### ErnieM

Joined Apr 24, 2011
8,167
Got a schematic?

Got a definition of "works"?

How did you program MCLR? If it is set to be clear (and not I/O) do you have a pull up resistor on it?

#### spinnaker

Joined Oct 29, 2009
7,835
Hi,

An intermittent PIC problem has returned

3x 18F2431 Programmed using Pickit2 and 3, with added voltage supply. I've read two different PICs using MPLAB and compare the HEX files, the same.

They were programmed using an adapted socket which GNDs PIN 28.

PIC1: Works most times, and once started works fine. I noticed that the PIC is not on the adapted socket, so all free pins are floating. There is a LED toggle to show that the PIC has initialised. If the PIC doesn't initialise, I can touch pin 28 (Or the circuit reset button) and it initialises. If I put the PIC on the adapted socket it doesn't work. If I don't use a socket it works. If I set up all free PORTB PINs to 0 (including PIN28) it doesn't work.

PIC2 and 3: Don't work under any conditions. They work otherwise.

I checked the circuit board for tracking between the PINS/TRACKS ok, and a motor for continuity of tracks, where I could.

Any ides of the likely problem welcome please.

Camerart.
It didn't happen without a schematic.

All unused pins are floating. Does this include MCLR? If so there's one of your problems.

#### nigelwright7557

Joined May 10, 2008
532
Sounds like you don't have a pull up resistor on reset pin. A 10K will be fine.
You can also program PIC to ignore reset pin.

#### MMcLaren

Joined Feb 14, 2010
853
Do you have LVP (Low Voltage Programming) disabled in CONFIG? If not, are you pulling up the PGM pin?

#### camerart

Joined Feb 25, 2013
2,600
Do you have LVP (Low Voltage Programming) disabled in CONFIG? If not, are you pulling up the PGM pin?
Hi M,

C.

#### camerart

Joined Feb 25, 2013
2,600
Hi,

QEI_PWM1c--18F2431 AZ LVP 8MHz INT 110415 is the program.

See program DEFINE CONFIG4L, I think it is programmed for LVP. I normally use PICKIT2 with no extra power supply.

EDIT: There is a 10K pull up on RESET/MCLR PIN, but I'm not sure how it is programmed.

I hope I've answered all of the questions.

NOTE1: For testing the 18F2431 PICs, I inject the required data (e,g, A123E123) into PIN18 RX, from a computer terminal, and read the resulting data from PIN17 TX into a second terminal. The output of the 18F2431 PICs got to an H-Bridge, and motors move, also I can see on an oscilloscope, when it is working.

NOTE2: When it is not working and the reset button is pressed and the initialising LED flashes, it still does not work.

C.

Last edited:

#### ericgibbs

Joined Jan 29, 2010
13,242
hi C,
Why is LVP Enabled.???
E
Code:
Define CONFIG1L = 0x00
Define CONFIG1H = 0x08  '8MHz INT
Define CONFIG2L = 0x0c
Define CONFIG2H = 0x20
Define CONFIG3L = 0x04
Define CONFIG3H = 0x80
'Define CONFIG4L = 0x80  'LVP= 0 = Set for HVP
Define CONFIG4L = 0x84  'LVP= 1 = Set for LVP
Define CONFIG4H = 0x00
Define CONFIG5L = 0x0f
Define CONFIG5H = 0xc0
Define CONFIG6L = 0x0f
Define CONFIG6H = 0xe0
Define CONFIG7L = 0x0f
Define CONFIG7H = 0x40
Also /MCLR is being used as agreed, with a PU resistor.
Ref image from Oshonsoft.

#### Attachments

• 31 KB Views: 6

#### camerart

Joined Feb 25, 2013
2,600
hi C,
Why is LVP Enabled.???
E
Code:
Define CONFIG1L = 0x00
Define CONFIG1H = 0x08  '8MHz INT
Define CONFIG2L = 0x0c
Define CONFIG2H = 0x20
Define CONFIG3L = 0x04
Define CONFIG3H = 0x80
'Define CONFIG4L = 0x80  'LVP= 0 = Set for HVP
Define CONFIG4L = 0x84  'LVP= 1 = Set for LVP
Define CONFIG4H = 0x00
Define CONFIG5L = 0x0f
Define CONFIG5H = 0xc0
Define CONFIG6L = 0x0f
Define CONFIG6H = 0xe0
Define CONFIG7L = 0x0f
Define CONFIG7H = 0x40
Also /MCLR is being used as agreed, with a PU resistor.
Ref image from Oshonsoft.
Hi Eric,

It must have been a choice between two past programs.

Is LVP 3.3v and HVP 5V ? If so I can see that it should be HVP.

Thanks, C.

#### camerart

Joined Feb 25, 2013
2,600
Hi Eric,

What happened to simple programming I'm still trying to understand it all.

Bearing in mind that I've compared the HEX files of the 'working' and none working PICs and they are the same.

Is it possible to program a PIC in such a way where it could have an intermittent fault?

C.

Last edited:

#### Papabravo

Joined Feb 24, 2006
16,486
It is simple programming. You simply have to know and nail down each and every possible configuration choice. It is the ONLY way to go.

#### camerart

Joined Feb 25, 2013
2,600
It is simple programming. You simply have to know and nail down each and every possible configuration choice. It is the ONLY way to go.
Hi PB,

What I meant by simple programming was that I used to use a simple programmer (Velleman) but perhaps all this was applicable then, and I got away with it.

C.

#### spinnaker

Joined Oct 29, 2009
7,835
Hi PB,

What I meant by simple programming was that I used to use a simple programmer (Velleman) but perhaps all this was applicable then, and I got away with it.

C.
There is another problem. Get yourself a pick it iii. And we are still waiting on the schematic.

#### spinnaker

Joined Oct 29, 2009
7,835
Found it on that other thread. You sure make things difficult for others to help. Is mclr floating? It is not immediately apparent as to how it is wired.

#### camerart

Joined Feb 25, 2013
2,600
Found it on that other thread. You sure make things difficult for others to help. Is mclr floating? It is not immediately apparent as to how it is wired.
Hi S,

sorry for the confusion.

The MCLR is pulled up by a 10K resistor.

C.

#### spinnaker

Joined Oct 29, 2009
7,835
Do you have a bypass capacitor? How is the circuit wired? Is it a PCB or is it a perf board? If prefboard have you checked all of your connections? If PCB have you checked all of your solder joints? Any cold solder joints?

#### camerart

Joined Feb 25, 2013
2,600
Do you have a bypass capacitor? How is the circuit wired? Is it a PCB or is it a perf board? If prefboard have you checked all of your connections? If PCB have you checked all of your solder joints? Any cold solder joints?
Hi S,

C.

#### camerart

Joined Feb 25, 2013
2,600
Hi,

Can someone double check for me please, is the MCLR pin set correctly in the program?

C.

#### Attachments

• 356.2 KB Views: 5
• 87.6 KB Views: 5

#### spinnaker

Joined Oct 29, 2009
7,835
Hi S,