Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Tools
Old 31st May 2008, 03:48 AM   #1
Default HIGH and LOW priority interrupt in 16f877 PIC using C programming

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 by cgsumesh77; 31st May 2008 at 03:49 AM.
cgsumesh77 is offline  
Old 31st May 2008, 03:55 AM   #2
Default

Quote:
Originally Posted by cgsumesh77 View Post
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.
__________________
=========================
Futz's Microcontrollers & Robotics
=========================

Last edited by futz; 31st May 2008 at 03:58 AM.
futz is online now  
Old 31st May 2008, 04:32 AM   #3
Default

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
Mike, K8LH is offline  
Old 31st May 2008, 02:38 PM   #4
Default

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
cgsumesh77 is offline  
Old 31st May 2008, 03:51 PM   #5
Default

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 by Mike, K8LH; 31st May 2008 at 03:53 PM.
Mike, K8LH is offline  
Old 31st May 2008, 03:54 PM   #6
Default

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.?
__________________
Eric " Good enough is Perfect "
I will NOT answer PM's requesting technical help, please use the Forum
PIC tutorials: Nigel's www.winpicprog.co.uk/ Bill's: www.blueroomelectronics.com/

Last edited by ericgibbs; 31st May 2008 at 03:57 PM.
ericgibbs is offline  
Old 31st May 2008, 03:59 PM   #7
Default

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
cgsumesh77 is offline  
Old 31st May 2008, 04:03 PM   #8
Default

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
cgsumesh77 is offline  
Old 31st May 2008, 04:12 PM   #9
Default

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 by Mike, K8LH; 31st May 2008 at 04:13 PM.
Mike, K8LH is offline  
Old 31st May 2008, 04:17 PM   #10
Default

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.
cgsumesh77 is offline  
Old 31st May 2008, 04:18 PM   #11
Default

i refered to the pwm module can generate 1.2 khz minmum...
cgsumesh77 is offline  
Old 31st May 2008, 04:40 PM   #12
Default

How many pwm outputs?
Mike, K8LH is offline  
Reply

Tags
high, interrupt, low, pic, priority, programming

Thread Tools
Display Modes


Similar
Title Starter Forum Replies Latest
URGENT!! 16F877 & USART & Interrupt & Recieve Problem DaMieN Micro Controllers 0 18th September 2007 11:53 AM
Priority Interrupt Controller Stellarcore Datasheet/Parts Requests 14 13th September 2007 05:14 PM
16F877 Timer0 Interrupt Affecting ADC sebana Micro Controllers 13 12th September 2007 10:43 AM
Need help programming 16F877 kittydog42 Micro Controllers 6 18th April 2007 11:08 PM
External Interrupt not working - 16F877 usaf1 Micro Controllers 0 15th September 2003 01:17 AM



All times are GMT. The time now is 11:36 PM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker