View previous topic :: View next topic |
Author |
Message |
dehan
Joined: 28 Jun 2012 Posts: 1
|
Interrupts |
Posted: Thu Jun 28, 2012 6:58 am |
|
|
I want to increment a counter, when an external push button connected to my pic ic 16f877a is pressed. I am quite new to interrupts and have no idea on how they work. Can you give me a very basic coding with line by line explanation of how this is done. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9225 Location: Greensville,Ontario
|
|
Posted: Thu Jun 28, 2012 1:40 pm |
|
|
There are several example programs that CCS kindly supplies in the examples folder.Some of those do use interrupts and have the information you need to complete your project.
I'm quite busy at my other job, organic farming, and cannot afford to spend the time to cut the code you want, unless you can wait for 3 weeks.You'ld also have to supply the crystal you're using as well as which pin the interrrupt will occour on.PB7...4 or PB0 would be the obvious choices.
Now if you want to come here and tear apart a 60 year old tractor and fix it, I'll cut the code while you fix my problem .
Seems fair to me.
hth jay |
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Thu Jun 28, 2012 2:02 pm |
|
|
Nice one Jay.
No, seriously he's right, this a help forum, NOT a do it for you.
Show us that you have tried and we will gladly assist.
It's useful for you to read the CCS forum guide.
Mike |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19505
|
|
Posted: Thu Jun 28, 2012 2:32 pm |
|
|
Also, there may be severe "doubt's" about whether an interrupt on the button is the right solution. Buttons tend to _bounce_. When pushed, you can often get several connection pulses one after the other. Using an interrupt, you will count every one. Hence better in general, for something as slow as a button, to use a 'tick' timer, and verify that once the button is made, it is still made a few uSec latter, and only then 'accept' it. There is keyboard code, in the code library, which demonstrates 'debouncing'.
Best Wishes |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
|