Set RB0 as input pin (set the TRIS as 1).In order to make the pin RB0 to handle interrupt these are the following steps So I will be setting the interrupt to work at the falling edge. When the switch is pressed, the pin voltage becomes zero. So now I will be connecting a switch pulled up to VCC. As you know I have been using PIC18F4550 here and according to the datasheet (screenshot below), RB0 is INT0. Usually PORTB has most of its pins with interrupt capability. Because I have seen people using some random pin out of nowhere and say interrupt is not working. Make sure the IO pin you are going to use for interrupt actually has interrupt feature. I encourage you to read the datasheet in order to understand much better about interrupt registers. The timer interrupt will be covered later in the timer chapter. This post will have only the input from pin change. I am not going to cover the difference between C18 and XC8 (XC8 makes your life a lot easier), but I’ll show you how to use interrupts in XC8. Now setting up interrupts is as simple as using the keyword “interrupt” before the function which should be called when an interrupt happens. With XC8, using interrupts is programmatically simple, since most of the code layout is given to you by. I’m sure if you reached this post in need of using interrupts (or having trouble with interrupts), then I assume you know what interrupts are and what you are trying to use. Interrupts! You use them to detect the change in pin status, timers, communication and so on.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |