April 15, 2024

Network System

Une technologie unique

PIC Programming With the Fundamental principles – Article 3

3 min read

Working with the Interrupt Program

This is the 3rd posting which will teach you how to programme the PIC working with c language. (We are working with MicroC for this example). In advance of continuing this article, you have to refer the initial 2 post which will give you the pretty fundamentals of programming. If you really certain on individuals fields, then its ok. So we will proceed type there.

As in the earlier article content, we’ll keep on as actions.

Step1: Make a new venture for this process. I am confident that now you are in a position. If not you should refer the first two content articles, PIC programming with the Fundamentals…. Post 2.

Action2: We will be doing a lot more examples on coding. Until then you should duplicate this coding part and paste it in the coding window.

Stage3: In this situation, a pin (PORTC.f7) will be blinking right until an interrupt is presented. When it receives an interrupt, it will promptly off the blinking pin and a further pin will established to superior. (PORTC.f5)

Initially of all, you will have to comprehend about the Interrupt. Really in denotes the same indicating. When you received an interrupt, what will you do? Defineatly you will go to to that interrupt and then proceed of your former function.

Permit me get an illustration. Just think, you are examining a novel when no human body is at home. Assume the novel is extremely fascinating. So you are preserving on examining with out executing any.

But what will occur, suddenly if the cellular phone is ringing? Although the novel is attention-grabbing, you want to read is continuously, you have to preserve it that location and have to go and solution the telephone. Just after that what will you do? After ending the simply call, you are coming to that very same area and get the reserve and continue on where you stop at previously.

Interrupt denotes the similar illustration. Your programme will continue on. That indicates your Primary programme will keep on. When an interrupt is gained, the main programme will be stopped, and get in to the Interrupt Plan. After finishing it, it will mechanically appear to the placement the place he stops earlier and carry on from there.

So now you have an notion of the interrupt. So we will proceed to coding portion once more.

Below is the code:

void interrupt()





void primary()









We will go over about coding afterwards. Until eventually then I am going to make clear earlier mentioned code promptly.

Initially jogging approach is the Most important process. At the commencing, PORTB is assigned to the input, PORTC is assigned to the output.INTCON register should have to have to assigned like that. It will enable the Global Interrupt Enable bit, PORTB- interrupt on.

Then it will continue on to the later on aspect. Until finally you are switching off the pic, it will blink a pin with 250ms intervals.

But when an interrupt is received to the PORTB.f0 pin, the principal programme will be stopped and it will operate the Interrupt routine. It will switch off the PORTB.f7 pin to Zero, established PORTB.f5 pic to high. The hold off is applied to keep in that system some time. Right after the delay, it will appear to the most important programme once again and carry on the programme. Thatmeans blink the bulb all over again.

The Proteus simulation interface is specified beneath.

You can now test the programme.

If there are any recommendations, you should use the comment segment.

Many thanks (Admin)

Leave a Reply