PIC Programming With the Fundamental principles – Write-up 3
Working with the Interrupt Routine
This is the 3rd post which will educate you how to programme the PIC making use of c language. (We are utilizing MicroC for this instance). Prior to continuing this write-up, you have to refer the initial 2 article which will give you the quite fundamentals of programming. If you very guaranteed on all those fields, then its okay. So we will keep on kind there.
As in the earlier articles, we’ll continue on as actions.
Stage1: Make a new project for this process. I’m guaranteed that now you are equipped. If not make sure you refer the initially two posts, PIC programming with the Basic principles…. Post 2.
Phase2: We will be doing far more examples on coding. Right until then remember to duplicate this coding component and paste it in the coding window.
Action3: In this situation, a pin (PORTC.f7) will be blinking right up until an interrupt is offered. When it receives an interrupt, it will immediately off the blinking pin and another pin will set to substantial. (PORTC.f5)
Initial of all, you should recognize about the Interrupt. Really in denotes the exact this means. When you obtained an interrupt, what will you do? Defineatly you will show up at to that interrupt and then continue of your preceding function.
Let me get an case in point. Just assume, you are reading a novel when no body is at dwelling. Suppose the novel is pretty intriguing. So you are trying to keep on looking through with out doing any.
But what will transpire, instantly if the phone is ringing? Although the novel is attention-grabbing, you want to go through is constantly, you have to maintain it that spot and have to go and remedy the cell phone. After that what will you do? Soon after ending the contact, you are coming to that similar position and get the e book and keep on the place you stop at earlier.
Interrupt denotes the exact same example. Your programme will carry on. That implies your Primary programme will proceed. When an interrupt is gained, the key programme will be stopped, and get in to the Interrupt Regime. After ending it, it will mechanically arrive to the posture where he stops previously and carry on from there.
So now you have an idea of the interrupt. So we will continue on to coding segment all over again.
In this article is the code:
void interrupt()
if(INTCON.INTF==1)
PORTC.f7=
PORTC.f5=1
hold off_ms(2500)
void most important()
INTCON=0×90
TRISB=0xff
PORTB=0×00
TRISC=0×00
PORTC=0×00
although(1)
PORTC.f7=~PORTC.f7
delay_ms(250)
We will examine about coding later. Until eventually then I am going to describe over code swiftly.
To start with running system is the Principal system. At the beginning, PORTB is assigned to the enter, PORTC is assigned to the output.INTCON sign-up really should need to assigned like that. It will enable the Worldwide Interrupt Empower bit, PORTB- interrupt on.
Then it will continue to the later component. Until finally you are switching off the pic, it will blink a pin with 250ms intervals.
But when an interrupt is obtained to the PORTB.f0 pin, the most important programme will be stopped and it will operate the Interrupt program. It will switch off the PORTB.f7 pin to Zero, established PORTB.f5 pic to substantial. The delay is used to remain in that system some time. Immediately after the hold off, it will appear to the primary programme yet again and keep on the programme. Thatmeans blink the bulb once more.
The Proteus simulation interface is supplied beneath.
You can now examination the programme.
If there are any ideas, please use the remark section.
Many thanks (Admin)