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.

HIGH and LOW priority interrupt in 16f877 PIC using C programming

Status
Not open for further replies.

cgsumesh77

New Member
hi guys,

is any one aware how to prioritise interrupt in 16f877..??
i know 0x4 is the starting address of high priority interrupt.. what about low priority interrupt. is there any specific registers other than gie, PIEI and corresponding interrupt enable need to be set for low priority interrupt.


can some one please help me by letting me know how to set a high and LOW priority interrupt in detail...??

i am having two routines and is some what conflicting or rather interfereing in running the code, so i want to set the second isr to be low priority.
the micro controller is PIC 16f877

thanks and regards
 
Last edited:
is any one aware how to prioritise interrupt in 16f877..??
i know 0x4 is the starting address of high priority interrupt.. what about low priority interrupt. is there any specific registers other than gie, PIEI and corresponding interrupt enable need to be set for low priority interrupt.
I think you may be thinking of 18F PICs, which do have high and low priority interrupts, with $04 as the high priority vector and $18 as the low priority vector. 16F's, as far as I know, have only one priority level and one interrupt vector ($04). All interrupts are high priority in a 16F877. Beyond that you'd have to figure out your own method of prioritization.
 
Last edited:
Please tell us about the conflict so that we might offer suggestions or alternatives? It doesn't hurt to have other people look at a problem from different perspectives.

Mike
 
actually i am using RCIF interrupt method to extract RFID reader values(12 bytes) through serial port. and also i have a timer for servo and port B interrupt also... when i only had serial communication interrupt, it worked so fine. but when i added these two more routines, at times the RFID reader is still working but at times not reading, that means the RFID tag reading is not that efficient, some times it doesnt even read... but majority of time it does...


so what i am thinking of is that in case if a serial data is ready in RCreg and before i move it, if some other interrupt happens then it will go there and my serial communication will be affected... to me my serial comunication is the at most priority, coz i cant have a miss or in correct reading. thats why i wanted to prioritise it so that there wont be any interference.

i had this idea in my mind to disable the global interrupt once the RCIF interrupt occurs and den enable the GIE it back after i do the ISR for RCIF...

i donno whether it would be of help, let me try... and i will keep u guys updated...

thanks for the response
 
Thank you for the explanation.

What is the interrupt rate for your timer driven Servo code? Is this periodic interrupt rate fast enough to allow you to poll the PORTB signal and the RCIF flag instead of using interrupts for those two signals? Usually you have plenty of time to pull serial data after the RCIF flag is set unless you're using an extremely high serial baud rate.

Mike
 
Last edited:
hi,
As futz states, only one interrupt vector 0x0004

Do you have an ISR at the 0x0004 address which saves the states of the important registers, before you service the caller.?

Inside the ISR place the serial Intr test first followed by the other two interrupt tests.
When you enter the ISR then you can detect which interrupt source has generated the interrupt.

If its absolutley critical you dont miss any serial data, once you enter the ISR and its a serial Intr, keep reading the RXD register until you get the terminator code for the string or the correct string length count.


Do you follow.?
 
Last edited:
for the servo code, am generating a 50 hz (20 ms delay), and am generating it with 2 as prescaler as anything above is giving a stacking of servo. so its like 20Mhz crystal /4 giving 200ns x 2 as pre-scaler and 254 is loaded to the tmrh register

and port B interrupts are essential because i am having a main program running in the back round to do some continous task and this Port b inputs are independant of main program code...

i used RCIE using interrupt method because i was afraid that if i use it with polling method and what if the interrupt occurs frequently and i might miss the bytes send by the RFID reader
 
hi ericgibbs...

there is a small issue that, if i keep on reading the rcreg until i get the full code my servo wont get the required pwm and to add to previous post my baud rate of serial communication is 2400 bps
 
Please tell us more about your Servo code, please? Are you using CCP module PWM mode? Are you using a single Servo or multiple Servo outputs?

What are your Port B inputs? Are they switches? Sensors?

You have about 4.17 msecs between incoming characters when using 2400 baud.

Mike
 
Last edited:
am using timer1 to generate the pwm and the width variation is done according to the main routine... i realized that 1.2 khz is the minimum frequency obtainable if i am using 20 mhz crystal, port b inputs are two IR sensors and a proximity sensor.. out of which the one IR sensor is used for counting and proximity has to respond when ever some thing blocks the way and the third one is to identify once the end is reached.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top