# Problem with PIC16f876 in MPLAB 6.60 as the PIC resets all the time

Status
Not open for further replies.

#### Tulkas

##### Member level 4
Hi, i have been using pics several years and i have never had this problem. Few time after pic start running it reset. I have not programed it with watchdog and other configuration bits wich could cause the reset. i have used debugger of the mplab and i can see something extrain. I use some delays subroutines and they are used continuosly during the program, but there is a point in the code where there is a call to a delay subroutine and in that subroutine there is other call to other delay subroutine, when the second call is executed the value of the stack in the first position change to the initial position of the code, and then when it execute the second return the program reset. I have this:

Code:
          ORG     0x000

goto    ini

ORG     0x004
.
.
.
retfie

ORG     0x100

ini
.
.
.
call    delay1
.
.
goto   \$

delay1
.
.
call   delay2
return

delay2
.
.
.
return

end

Always the stack change to the first position of the code in 0x101, if i write the code in ORG 0x60 for example stack change to 0x61, for that reason i'm not sure that a reset take place, and there isn't any jump to the label 'ini'. Anybody can help me?.

Sorry for my english, sorry for the post, sorry for all. Thanks

#### gidimiz

pic resets all time

Hi,

What PIC are you using?
Also, try to download from the Microchip web site the Errata and see if there is anything there that you might be doing.

If you found my answer useful, click on the button that says Helped me. ( NO points will be taken from you! )

Good luck.

### Tulkas

Points: 2

#### DarkJedi

##### Full Member level 2
Re: pic resets all time

It could be because you have a lot of code writen between the returns. It's been so long since i dont use PIC, as long as i recall, the jumps in a program are not to any position you want, there are boundries to those jumps depending on the instruction you use to do the jumps.

Like using relative jumps to XX instructions before, you can not use this instruction to do long jumps ause the pointer have those boundries and when it excedes the number of iunstructions it resets and starts counting again from 0.

Check the datasheet for the description on the jumping instructions.

Take it easy.

#### sp

##### Full Member level 6
pic resets all time

check ur MCLR... check whether it is pull high enuff...

low MCLR will make the pic not stable n it will keep on hardware reset...

sp

#### are

pic resets all time

Wat kind of PIC you are using?

Maybe you have a stack overflow.

#### Tulkas

##### Member level 4
Re: pic resets all time

I am using pic16f876 with MPLAB 6.60, i haven't stack overflow because i see it with debugger and i can see clearly what the pic is doing. With respect to the jumps and boundaries, i think with goto instruction you can access to all memory positions, i read that in datasheet, but i don't know if the same thing happens with call instruction, i need to have a look to the datasheet.

#### atferrari

##### Full Member level 4
Re: pic resets all time

The worst question: hardware or software

Have you tried, "commenting" routines one after the other to see when that resetting stops?

Or do it the other way round. Start with the real possible minimum and keep adding software to see when that starts happening again.

#### pvinbox@yahoo.com

##### Full Member level 2
Re: pic resets all time

did u used watchdog timer
if yes then u should clear the watchdog timer before it gets overflow
otherwise it will resets the controller

#### ckmai

##### Newbie level 2
Re: pic resets all time

I also have the same problem before.

Enabling LVP bit will cause your controller go into low voltage programming mode.
Thus, you will see that your controller go "reset".

#### jonw0224

##### Full Member level 4
pic resets all time

I agree with DarkJedi. Make sure you setup PCLATH correctly before your call. If it's jumping to 0x101 or 0x61 instead of 0x00, it's NOT a reset. Remember, call like goto gets the two high bits from PCLATH.

#### Tulkas

##### Member level 4
Re: pic resets all time

I am sorry to have been late so much in answering.

Thank you for everyting.

Status
Not open for further replies.

Replies
1
Views
2K
Replies
8
Views
3K
Replies
0
Views
2K
Replies
1
Views
2K
Replies
2
Views
668