On Tue, Oct 20, 2009 at 4:29 AM, h4ctic wrote: > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0bsf option_reg, intedg =A0 =A0 =A0 =A0 =A0= ; select interrupt on > rising edge of b0/int pin > bsf intcon, int0ie =A0 =A0 =A0 =A0 =A0 ; enable rb0/int external interrupt > intchk btfss intcon, rbif =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ; check int= errupt flag bit > goto intchk > movf portb, 1 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ; end mismatch condition > bcf intcon, rbif =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ; clear interrupt fl= ag > bsf portb, 1 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ; turn on led > btfss intcon, rbif =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ; check rbif bit > bcf portb, 1 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ; turn off led > retfie No, this routine does not contain interrupt -- thanks god GIE is not set as you have no ISR. This is a kind of polling you are doing right now, but there are many mistakes like you are clearing the rbif then you check if that is set or not... Or maybe I just can't understand what is really going on here as you try to set the interrupt on and service it in the very same routine. On the main you set up the interrupt, and then in the service routine you will just servicing, not setting and playing with the setting. And if you intend to make an interrupt servicing here then you should not put blocking mechanism in there iin the first place aka polling if RBIF is set in a tight loop, as it can cause dead-lock. 1. First of all you should show the entire program with the config bits and port / interrupt initialization routines as well as the ISR itself. 2. Never put label to the same line as an instruction (syntax allows that but that's a bad style) 3. Never start an instruction on the very first column of the line (syntax does not allow that but it still may compile) 4. Maybe the leading space thigy is mising because of your mail client, so it is better to attach the source then... 5. I can't remember you mentioned the type of PIC you are using, so maybe there are many things missing here like banking or maybe your PIC does not even support interrupts... 6. Read the PIC Midrange Manual about the interrupts and understand how it works (even if you are using other family of PIC) -- look at the context savings, how to determine what caused the interrupt, how to set this or that type etc. I am pretty sure 9 out of 10 (if not 10/10) of your PIC books also contain an interrupt chapter... Best Regards, Tamas > > On Tue, Oct 20, 2009 at 10:54 AM, Jinx wrote: > >> >> > this is exactly the type of info that is not in any book. thanks for >> this. >> >> You're welcome. What will best help you learn is a project that you >> design and program >> >> For example, if you want to track a square wave and light an LED, a >> simple way would be to poll the input. Say you have chosen B0 / INT0 >> as the input >> >> repeat >> >> btfss portb,0 ;wait here until the input goes high >> goto $-1 >> >> bsf led ;turn the LED on >> >> btfsc portb,0 ;wait here until the input goes low >> goto $-1 >> >> bcf led ;turn the LED off >> >> goto repeat ;go back to the start >> >> As you can see, that ties up the micro for 100% of its time and you >> can do no other work with it. If you use an interrupt then that frees >> up the micro to do other things. You'd set up the interrupt system to >> react to an INT0 event and alternate the edge trigger polarity. This >> process is quite straight-forward but can get quite involved depending >> on what else is happening in the software, so you need to account >> for everything and anything that could happen to ensure smooth running >> and good time management >> >> -- >> http://www.piclist.com PIC/SX FAQ & list archive >> View/change your membership options at >> http://mailman.mit.edu/mailman/listinfo/piclist >> > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > -- = /* www.mcuhobby.com */ int main() { char *a,*s,*q; printf(s=3D"/* www.mcuhobby.com */ int main() { char *a,*s,*q; printf(s=3D%s%s%s, q=3D%s%s%s%s,s,q,q,a=3D%s%s%s%s,q,q,q,a,a,q); }", q=3D"\"",s,q,q,a=3D"\\",q,q,q,a,a,q); } -- = http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist