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.

SETUP AN INTERRUPT IN 16f690

Status
Not open for further replies.
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.
 
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 !
 
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:
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,

Hi c360,
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.?
 
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
 
...........Thanks eric I have a push to on switch at hand ,will try that and tell you

Hi,
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.
 
Last edited:
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.

I don't understand your problem. I just typed the various values except for RA2 which I selected from the drop down box. Which bit can't you do?

Mike.
 
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:
I don't understand your problem. I just typed the various values except for RA2 which I selected from the drop down box. Which bit can't you do?

Mike.

hi Mike,
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..???
 
I'm using MPLAB V8.02, I just pick the value from the drop down box.:confused:

Mike.
 
Last edited:
I'm using MPLAB V8.02, I just pick the value from the drop down box.:confused:

Mike.

hi,
I have just downloaded from microchip MPLAB IDE V8.10, installing on my second PC, let you know.:)

EDIT:

Installed MPLAB IDE V8.10, I am now able to set up the Stimulus the same as you Mike. OK.

ie: restart at '0' etc.
 
Last edited:
Mine one does'nt have "0" so, I did something awkward, I have added 0 in time coloumn and for this 0 time I set RA2 to 1 and then I have 0 in the dropeout menu..........., oh god I can't go more easy than this in words ,Mike please tell me how did you attach the picture of stimulus window in your last post (I know how to attach a picture, but don't know how to copy an active window as a picture)
 
Mine one does'nt have "0" so, I did something awkward, I have added 0 in time coloumn and for this 0 time I set RA2 to 1 and then I have 0 in the dropeout menu..........., oh god I can't go more easy than this in words ,Mike please tell me how did you attach the picture of stimulus window in your last post (I know how to attach a picture, but don't know how to copy an active window as a picture)


hi,
Google for screenhunter its freeware.
 
To copy the screen, press the key that has "Prt Scr/SysRq" (next to scroll lock) on it and the screen is copied to the clipboard. Go into your favourite graphics program and paste it.

Mike.
 
O.K. so this is what I have done to get "0" in restart, is it right to do so?
And the simulatio still does'nt work, after doing whatever in the thumbline I clicked apply then svaed the workbook, so this supposed to work.
 

Attachments

  • image1.png
    image1.png
    15.6 KB · Views: 230
Last edited:
Hey ! that works , 500 and 1500 were too long period ( though I should have some patient, sorry for that)I reduce them to 50 and 150.:)
 

Attachments

  • image 2.png
    image 2.png
    15.6 KB · Views: 230
I guess you were using single step (F8). If you set a breakpoint as shown below, by double clicking in the grey border, then you can press f9 and the program will run until an interrupt occurs.

Mike.
 
Last edited:
I know that but, pressing F9 with a break point runs progarmme only for first interrupt(as it should be) and then when I press agin F9 to cross over break point the whole MPLAB gets hang, only animation runs good but, that takes too much time.
 
Last edited:
I know that but, pressing F9 with a break point runs progarmme only for first interrupt(as it should be) and then when I press agin F9 to cross over break point the whole MPLAB gets hang, only animation runs good but, that takes too much time.

It shouldn't do that, it should stop at the breakpoint every time you press F9. It might be worth downloading and installing the latest version.

Does it now work on the hardware. A good way to generate interrupts is to turn on the WPUs (WPUA=2 and OPTION.7 = 0) and then just ground the pin. The debounce problem shouldn't matter, it will just jump a few counts.

Mike.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top