![]() | ![]() | ![]() |
| | |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
| | Thread Tools | Display Modes |
| | (permalink) |
| Experienced Member | I want to going back to the same label after an interruption service ALWAYS letīs say I have this program Code: ... decisions: blablabla yadayadayada ... routine1: dothat dothis goto routine1 routine2: dothat dothis goto routine2 ... routine9001: dothat dothis goto routine9001 end |
| | |
| | (permalink) |
| Experienced Member | You put the address of the label you want to return to on the stack. When you execute the return from interrupt you'll get where you want to go. I don't recommend this approach for two reasons.
__________________ We never have time to do it right; but we always have time to do it over. |
| | |
| | (permalink) |
| Experienced Member | It can also lead to really nasty bugs. Image if you have a 32bit add routine on an 8bit processor and it is half way through dumping the answer, 8bits at a time, into a 32bit variable and your interrupt routine calls it away never to return. Use flags to do this.
__________________ --- The days of the digital watch are numbered. --- |
| | |
| | (permalink) |
| Experienced Member | In the case of no 32-bit add routine I guess its ok. Not a morality or legality thread. I have code in products that after a certain criteria is meet in the interrupt, I must always vector to a know location period. This was not true for every time the interrupt was called but after being called a set number of times. If its need then do it, block interrupts during 32-bit routines or whenever necessary. And whats the method of remember anything in code? Code: ;Vector to Sub "Decision" ;Reasons follow below: ;1.... ;2....
__________________ I can still log in! Delete my account and all my post now. |
| | |
| | (permalink) | |
| Experienced Member | Quote:
With AVR, this is easily done as one can modify the stackpointer or push/pop values from the stack. With 16F PIC, it is a bit more involved. You need to place(sometimes more than one) check bit instructions inside every routine and jump to "decisions" every time the bit is found set. Inside the ISR, you set that bit and return. On start executing the "decisions" code, you reset the bit to false.
__________________ L.Chung | |
| | |
| | (permalink) | |
| Super Moderator | Quote:
| |
| | |
| | (permalink) |
| Experienced Member | Back in the 80s it was quite normal to have you ISR jump to the start of your main loop. Your main loop processed all the critical game stuff before updating the screen. By placing things like updating the score and radars etc near the bottom of the main loop they would get "dropped" if things got too busy. No one ever noticed if the score/radar got updated because at this point they were too busy trying to stay alive. One classic that used this technique was Defender from Williams. Anyway, on a 16 series pic you could simply do, Code: org 4
goto RequiredCode Mike. Last edited by Pommie; 7th April 2008 at 09:04 AM. |
| | |
| | (permalink) |
| Moderator | A more common method is to have the ISR set a flag and handle the branch back to decisions handled in the main code. This mimics the action of a break within a loop. Code: decisions:
startOver = false
blablabla
yadayadayada
...
if (startOver is true)
then goto decisions
call routine1
if (startOver is true)
then goto decisions
call routine2
goto decisions
end You could shorten up the code with a macro or define.
__________________ search engine for electronic partsJunebug USB PIC programmer kit., USB Bit Wacker, Homepage The 15 Minute Printed Circuit Board! (+drill time) |
| | |
| | (permalink) | |
| Experienced Member | Quote:
__________________ We never have time to do it right; but we always have time to do it over. | |
| | |
| | (permalink) |
| Experienced Member | Ok then. Thank you for your comments gentlemen |
| | |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |
| | ||||
| Thread | Thread Starter | Forum | Replies | Latest |
| PIC16F628a Problem generating a RCIE interrupt | Norlin | Micro Controllers | 3 | 16th January 2008 01:43 AM |
| Priority Interrupt Controller | Stellarcore | Datasheet/Parts Requests | 14 | 13th September 2007 04:13 PM |
| Question about Interrupt | tinhnho | Micro Controllers | 3 | 11th February 2007 07:07 PM |
| how to give 120degree phase shift i've written a code | esconele | Micro Controllers | 18 | 16th February 2006 12:49 PM |
| Work ID reader Track 2 problems with pic code. Need help! | egg0900 | Micro Controllers | 2 | 19th April 2004 06:57 AM |