Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

problem with pic reset

Status
Not open for further replies.

Scolioza

Member level 1
Joined
Mar 5, 2013
Messages
34
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,561
Hi all.
Recently I bought a minimal dev board PCB for pic 16f877a. I assembled the hardware and I started to do some testing. The problem is that when I keep the reset button pressed the program, stops from executing but after realeasing the button the program does not reset the program counter so it continues from where it stopped. It s like I paused the program.
Here is the circuit.
**broken link removed**
In data sheet of pic it was a capacitor series with resistor, but in this ckt is ommited.
Could this be cause?
Thanks in advance!
 

First, what you are observing is in my opinion most unusual.

Things I would try are make sure the ISP is not plugged in and affecting the operation.

I always have a cap to ground from MCLR, but really can't see that could cause the observed effect.

So now a question, are you using a bootloader and if so could this be changing the behaviour?
 

You have some error in scematic diagram. The power pins are not connected and the pic not have filter capacitor on power rails.
If possible, please upload your code here.
 

Hi,

As Jamespond says you need to post your program code and also say what programmer or bootloader you are using and if its still connected ICSP when you try and run the program.

The Reset circuit circuit should be like this for ICSP.

If you are using the kits pcb then all the power pins should be connected, but worth checking , details in the picture.
 

Attachments

  • 000113.jpg
    000113.jpg
    33.3 KB · Views: 127

I use a pickit2 clone and is always plug out when I run programs. There are filter caps c1 and c2. Another strange thing is that when I stop the power by pushing s1 when I press again the button the program keeps running from where was left. I will upload the code asap.
Many thanks.
 

The connections in the picture is wrong ( PIN31 is (VSS = GND), not ((5V = VCC or VDD ) An hour is 5V, in another time is VCC )).

Names in the ICSP is wrong : Sequency is : | VPP | VCC | GND | DATA | CLK | LVP |

The LVP is missing too.

Where the source code??? Maybe the RESET is disabled in the fuses!!!

This is my schematic and suggestion (use 470 instead 1K from R4, like wp100 suggest):

PIC16F877A Proto.jpg

https://ww1.microchip.com/downloads/en/devicedoc/30277d.pdf

https://ww1.microchip.com/downloads/en/DeviceDoc/PICkit_3_User_Guide_51795A.pdf

Sorry for bad english!!!
 
Last edited:

Ok. Here is the code.

I double checked everything on pcb . It looks ok. The circuit was posted only for the reset part.


Code:
Define CONFIG = 0x2f42
Define ADC_CLOCK = 3
Define ADC_SAMPLEUS = 20

'LINE FOLLOWER //// PETRESCU CRISTIAN
TRISA = 255
TRISB = %00000001  'PORTB =OUTPUT

Symbol mstg = PORTB.1  'COMANDA MOTOR STANGA
Symbol mdr = PORTB.2  'COMANDA MOTOR DREAPTA
mstg = 0
mdr = 0
Dim val_ref(4) As Word  'VECTORI VALORI DE REFERINTA
Dim val_prg(4) As Word  'VECTORI VALORI CITITE
Dim dif(4) As Byte  'DIFERENTE
Dim semn(4) As Byte  'FLAG DE SEMNE
Dim indice As Byte  'POZITIA SENZORULUI
Dim max As Byte  'VALMAX
Dim contor As Byte
Dim buff As Byte
Dim calibrare As Bit  'CALIBRAREA INITIALA
Dim start As Bit  'INCEPEREA PROGRAMULUI
Dim x As Byte
Hseropen 19200


'SETAREA MODULULUI COMPARATOR

CMCON.CM2 = 1
CMCON.CM1 = 1
CMCON.CM0 = 1

'FIGURA 12.1 CONFIGURATIA 5 COMP off

'SETARE REG. A/D

'ADCON0.ADCS0 = 1
'ADCON0.ADCS1 = 1  'SEATARE OSC RC INTERN
'ADCON1.ADFM = 1  'SETARE RIGHT JUSTIFIED

ADCON1.PCFG3 = 0
ADCON1.PCFG2 = 0
ADCON1.PCFG1 = 0
ADCON1.PCFG0 = 0
'TOATE INTRARI ANALOGICE

'SETARE INTRERUPERI

INTCON.GIE = 1  'INTRERUPERI GLOBALE ACTIVATE
INTCON.PEIE = 1  'INTRRUPERI PERIFERICE ACTIVATE
INTCON.INTE = 1  'INTRERUPERE PE RB.0
'PIE2.CMIE = 1  'INTRERUPERI COMPARATOR ACTIVATE
PWMon 1, 2
PWMduty 1, 550
'########################################################
loop:


If calibrare = 1 Then
	For x = 0 To 3
		val_ref(x) = analog_read(x)
		Hserout "val:  ", #val_ref(x), CrLf
	Next x
Endif

If start = 1 Then
	
	For x = 0 To 3
		val_prg(x) = analog_read(x)
		
		If val_prg(x) > val_ref(x) Then
			dif(x) = val_prg(x) - val_ref(x)
			semn(x) = 1
		Else
			semn(x) = 0
		Endif
	Next x

	For x = 0 To 3
		If max < dif(x) And semn(x) = 1 Then
			max = dif(x)
			indice = x
		Endif
	Next x
	
	If max > 7 Then
	Select Case indice
		Case 0
				mstg = 0
				mdr = 1
		Case 1
			buff = dif(1) - dif(0)
			If buff < 7 Then
					mstg = 0
					mdr = 1
				Else
					mstg = 1
					mdr = 1
			Endif
			
		Case 2
			buff = dif(2) - dif(3)
			If buff < 7 Then
					mstg = 1
					mdr = 0
				Else
					mstg = 1
					mdr = 1
			Endif
			
		Case 3
				mstg = 1
				mdr = 0
	EndSelect
	Else
		mstg = 0
		mdr = 0
	Endif
Hserout "####################", CrLf
Hserout "stg1:", #dif(0), CrLf
Hserout "stg2: ", #dif(1), CrLf
Hserout "dr2: ", #dif(2), CrLf
Hserout "dr1: ", #dif(3), CrLf
Hserout "####################", CrLf
	For x = 0 To 3
		dif(x) = 0
	Next x
max = 0

Endif

WaitMs 1000
Goto loop

End                                               
Function analog_read(pas As Byte) As Word
		Select Case pas
			Case 0
				Adcin 3, analog_read
			Case 1
				Adcin 0, analog_read
			Case 2
				Adcin 1, analog_read
			Case 3
				Adcin 2, analog_read
			EndSelect
If calibrare = 1 Then calibrare = 0
End Function                                      

On Interrupt
WaitMs 1000
contor = contor + 1
	If contor = 1 Then calibrare = 1
	If contor = 2 Then start = 1
INTCON.INTF = 0
Hserout "####################", CrLf
Hserout "contor:", #contor, CrLf
Hserout "####################", CrLf
Resume
 

Attachments

  • conf.png
    conf.png
    56 KB · Views: 79

Wich compiler is used???

Sorry for my error, no have fuse for MCLR option!!!
 

PIC iDE Simulator.
I think I will make my own DEV board on perf board. About bootloader as far as i know there is none .
 

Hi,

Have you programmed your dev board and run any program properly ? eg a simple led flasher or a flasher activated by a switch ?

That would prove the oscillator circuit is working correctly and Mclre

Just because a program seems to work ok on a simulator does not always mean its ok to run on a dev board.


Try this simple 4 second PORT B flasher .hex program and see if it works ok ..?
 

Attachments

  • flash.zip
    228 bytes · Views: 49
Last edited:

As i said the program runs fine in real world (i mounted the motors optocouplers etc) but i cannot reset. The only option is to stop the power supply and wait a few sec (for caps discharging)).


I tried something similar with your program., and it is the same thing. I noticed another strange thing: instead of s1 switch i put a simple jumper which theoretically after is pulled out must stop the supply to pic but it is not happening. The vcc voltage drops to 1.2 V. I think this pcb is another fine product of china: -o . I will make my own and see if it s happening again.
 

I'm not a PIC programmer of latter years, tending to do my developmemnts with the mBed modules, but is the MCLR reprogramable?
Could it be doing some other function?
Also if removing the Power supply it is just amazing how little voltage is required to keep the PIC oscillating even if the outputs don't/can't drive anything!

I look forward to hearing the cause of MCLR switch just pausing the program....
 

Sorry for asking.
Do you want to simulate a brown reset? The voltage in this situation is 0.5V
 

actually what u want your program counter started 0 when MCLR pin hit to low right ya wrong?
 

If you are using 4MHz crystal oscillator, change fuse to XT instead HS...
 

Hi again.
The problem , as I suspected was the board. The 12th pin of pic (vcc) was wired before the power switch and the 32nd pin was wired after. Also there was problem with power supply of the rs232. Anyway i made my own devboard on perfboard and is working like a charm. If anyone is interested I will post some pictures with it.
Conclusion stay away of that pcb . Thank you all for your good advices.
 

ya post some picture might be help for me and any other !!
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top