![]() |
![]() |
![]() |
|
|
|||||||
| 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) |
|
Out of curiosity I simulated your code in MPLAB and toggled the RA2 pin every 1000 cycles. It did exactly as expected. The value on Port C went up to 9 and then back to zero.
Mike. |
|
|
|
|
|
|
(permalink) |
|
Yes eric I do follow that and thank you for that to the point answer but, what if I want to set more than one interrupt, I mean only one interrupt can start at 0x04
and I'm still waiting for that code to be solved please don;t forget that (this is for any one who usually jumps to the final post, so my problem is yet not solved, please read few preavious posts ) Last edited by c36041254; 17th May 2008 at 11:53 AM. |
|
|
|
|
|
|
(permalink) | |
|
Quote:
On Interrupt, the ISR [Interrupt Service Subroutine] at 0x0004 will have code at the start of the ISR which tests the Interrupt flag status of the Interrupts you have enabled. So: ISR: Save Flags and Wreg..etc Is TMR0 Interrupt flag Set If Yes, call the Timer0 subr or execute a string of code for the Timer0 ; Is TMR1 Interrupt flag Set. If Yes, do Timer2 subr ; Is PORTB on change Interrupt Set. If Yes do PORTB subr Restore Flags, Wreg etc RETFIE; return to the main program where you left it + 1 You can have any number of Interrupts in the ISR. This is a very basic explanation, but do you get the picture.?
__________________
Eric "Good enough is Perfect" PIC tutorials: Gramo's: www.digital-diy.net/ Bill's: www.blueroomelectronics.com/ |
||
|
|
|
|
|
(permalink) |
|
O.K. so this is what I make out of it:
When an interrupt occur the programme jumps to 0x04 and check for which (external,timer etc.) the interrupt has encountered and execute the appropriate interrupt routin (I mean code not routine as thee would be only one interrupt routin for all interrupts). Thanks! (this is for any one who usually jumps to the final post, my problem is yet not solved, please read few preavious posts ) |
|
|
|
|
|
|
(permalink) | |
|
Quote:
I have read the previous posts, can you restate your problem.
__________________
Eric "Good enough is Perfect" PIC tutorials: Gramo's: www.digital-diy.net/ Bill's: www.blueroomelectronics.com/ |
||
|
|
|
|
|
(permalink) |
|
Your code (now) works fine in the simulator and so I would guess that your problem is hardware. Do you have MCLR tied high? Can you do something simple like just lighting the LEDs?
Mike. |
|
|
|
|
|
|
(permalink) |
|
Actually I'm using low pin count demo board supplied with PIC Kit 2, and I'm touching a wire from Vdd to RA2 and then connect it to GND manualy, but as you said that it runs well on simulation I'll check the hardware, by the way, I am tryiing to simulate the codes but don't know how to use stimulus , I have selected pin/register actions from stimulus window then add a signal for RA2 (that has generated a coloumn for RA2), then I ticked repeat and set it for 5 sec,what else I need to do, I been through help file but that is rather confusing. I'm sorry that I ask too much but I'm studying correspondently so internet is the only source where I can learn from and thank you all for the help !
|
|
|
|
|
|
|
(permalink) |
|
I just setup the stimulus as shown in the attachment and then do apply. I then set a breakpoint on the first instruction after org 4 (movwf temp) and run it with F9. If you view the SFRs you can see port C increment.
Mike. Last edited by Pommie; 6th July 2008 at 04:12 PM. |
|
|
|
|
|
|
(permalink) | |
|
Quote:
Touching A2 to Ground and Vcc with a piece of wire is about the worst thing you could do to generate an Interrupt!. You will generate multiple interrupts. The only reliable way is to use a momentary switch or push button, connect A2 to Vcc with a 4K7 resistor and use the switch to connect A2 to ground. The switch should also be debounced by using a simple resistor/capacitor filter between the switch and A2. Do you follow.?
__________________
Eric "Good enough is Perfect" PIC tutorials: Gramo's: www.digital-diy.net/ Bill's: www.blueroomelectronics.com/ |
||
|
|
|
|
|
(permalink) |
|
How could you be able to set "restart at 0" while there are only 500 and 1500 in time coloumn, I am having problem setting "restart at 0", I have added "0" in time coloumn and respectively put "1" in RA2 coloumn (I could have explained better by sending a pic., how did you copy the whole window as thumbline ?), but that did'nt work, in SFR port c shows all zeros.
...........Thanks eric I have a push to on switch at hand ,will try that and tell you |
|
|
|
|
|
|
(permalink) | |
|
Quote:
Drawn a pic to explain a little better. However careful you are touching a PIC input pin with a piece of wire, chances are you will get multiple contacts and the PIC will act in a unpredictable way. There are software routines that are used to debounce switch contacts that are being 'polled' by the program, but for switches which generate an Interrupt I have found it better to add hardware debouncing. EDIT: I would also use hardware debouncing [opt#2] when using the PIC Timers as counters with external clocking inputs.
__________________
Eric "Good enough is Perfect" PIC tutorials: Gramo's: www.digital-diy.net/ Bill's: www.blueroomelectronics.com/ Last edited by ericgibbs; 7th July 2008 at 11:24 AM. |
||
|
|
|
|
|
(permalink) | |
|
Quote:
Mike. |
||
|
|
|
|
|
(permalink) |
|
I knew this will happen
O.K. ,when I go to the restart box the drope out menu appears and it has only two values 500 and 1500 so, how did you select "0" because the value (0) must be in the drope out menu but as I said it (0) is not there. If you still don't get what I'm referring to then tell me how did you make thumbline of the whole stimulus window because I don't know how to do that otherwise I would have sent you a picture of mine stimulus window which I hope have served better, so please tell me how to save stimulus window in picture (JPEG or any other) format so as to post it on blog (just as you did to explain me), I hope this will be understandable. Oh! and thank you eric for your ckt this will take some time to build ,so will tell you later about that. Last edited by c36041254; 18th May 2008 at 12:12 PM. |
|
|
|
|
|
|
(permalink) | |
|
Quote:
Which version of MPLAB are you on.? , I'm using V7.6, got the same problem as OP. No '0' option a restart, just 500 and 1500 I wonder if he is also using V7.6..???
__________________
Eric "Good enough is Perfect" PIC tutorials: Gramo's: www.digital-diy.net/ Bill's: www.blueroomelectronics.com/ |
||
|
|
|
|
|
(permalink) |
|
I'm using MPLAB 8.0
|
|
|
|
|
| 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 |
| Help with timer and interrupt please.. | AntRoFiZ | Micro Controllers | 2 | 29th May 2007 11:48 AM |
| Question about Interrupt | tinhnho | Micro Controllers | 3 | 11th February 2007 07:07 PM |
| Interrupt on GP Change problem | Dan East | Micro Controllers | 2 | 22nd May 2004 05:12 PM |