Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Tom Brown

Status
Not open for further replies.

tombro73

New Member
I have difficulty getting both Interrupts to work on the 16F876, is there any known problem with this chip.
What I would like to do is jump out of an Interrupt with a GOTO and just ignore the return address on the stack. As far as I can tell this would require a cicular stack so that addresses could just drop off. Do any of the 18Fxxx chips have a circular stack, or any other chips.
Many Thank
newbie
tom brown
 
Just pop the stack into a junk register before you goto
 
Last edited:
Bad programming practice as you'll cause a stack overflow pretty quick.

You can manipulate the stack with the 18F but it's still not the right way to work with interrupts.
 
It depends blueroom. In an interrupt if you need to truly jump out of that routine and bypass the normal interrupt process for exceptions as long as you pop the information off the stack and set the interrupt enable/disable or other register save/restore. It's only bad coding practice if you're a bad coder. It is however seldom needed.

It's generally smarter to use a custom status byte set a bit in there for a specific condition, and have your main loop check for that condition in that register. Basically it's software interrupts. Less code less hassle, less possibe chance for you to screw it up.
 
Last edited:
I agree with Bill, it's really bad practice - you shouldn't be writing anything which needs to do such a thing.

In any case, if he needs to ask, he's no where near competent enough to get away with doing it.
 
stack pointer

Sceadwian, thanks
Since there is no POP instruction the "retfie" will return to the point where the interrupt occurred, which is not what I want.
The program runs on a PWM timer, and Timer0 is used to use various times, and when new data is entered with RB1 interrupt. the routine needs to restar with the new data, and not jump back into the old data process.
Using a marker byte, and software polling it is not really what I want.

Blueroom, thanks
I understand the stack overflow, that is what the problem is because I don't see any way to modify the stack pointer. If there is a method to change the stack pointer (say on an 18F) then this would be OK, but my problem there is that on reading the data sheet, I don't see any mention of changing the pointer.

Nigel, thanks
I know that it is bad practice but it seems to me that this is a failing of the 16Fxxx chip.

There is no mention anywhere in the data sheet that I can find, (both 16F and 18F) whetherbthe stack is circular or linear, which is the reason for my question.

Hope I am right in my assumptions.

tombro73
 
Sceadwian, thanks
Since there is no POP instruction the "retfie" will return to the point where the interrupt occurred, which is not what I want.
The program runs on a PWM timer, and Timer0 is used to use various times, and when new data is entered with RB1 interrupt. the routine needs to restar with the new data, and not jump back into the old data process.
Using a marker byte, and software polling it is not really what I want.

I would suggest you change the way your entire program works, it's poor practice because you're going about it the wrong way.

Nigel, thanks
I know that it is bad practice but it seems to me that this is a failing of the 16Fxxx chip.

It's bad practice on ANY chip, it strikes me as it's a good idea the PIC makes it harder to do such a poor thing.
 
There is no mention anywhere in the data sheet that I can find, (both 16F and 18F) whetherbthe stack is circular or linear, which is the reason for my question.

Hope I am right in my assumptions.

tombro73

The stack is FILO (first in last out) like a plate warmer in an institutional dining room. The first plate put on the stack is on the bottom and comes off last. The last plate put on the pile is taken off first. If you don't take the plates you put in out, then it won't take long for the thing to overflow.

I'm not sure, but the info may be in the family reference manuals.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top