OK. You put whatever you want your processor to do whenever an interrupt happens. And that is VERY application depending... :-) Noone else that you know what your code should do, can we? Note that the function with the "interrupt" attribute is just as any other function in your code. The only difference is that you never make a direct call to it from your main() code, it is called automaticly by the interrupt hardware logic within the processor whenever an interrupt happens. But besides of that, the ISR containse just ordinary XC8 code just as any other code in your application. Jan-Erik. Richard R. Pope wrote 2014-07-19 21:07: > Jan-Erik, > I'm sorry but I still don't get it. What do I put in where it says > 'Enter your code here'? > Again I'm sorry, > rich! > > On 7/19/2014 1:58 PM, Jan-Erik Soderholm wrote: >> This is of course a question for the list as a whole... :-) >> >> But, you put that anywhare in your C source just as you >> would do with any other C function definition. >> >> A short cut down example from a working code >> using a Timer0 interrupt: >> >> ------------------------------------------------ >> // CONFIG1 >> ... >> // CONFIG2 >> #pragma config WRT =3D OFF >> ... >> >> #include >> >> void interrupt myint (void) { >> if (TMR0IE && TMR0IF) { >> TMR0IF =3D 0; >> ... >> ... >> return; >> } >> } >> >> void init(void){ >> ... >> ... >> // Setup of ports, timers, interrupts and so on. >> return; >> } >> >> void main(void) { >> init(); >> ei(); >> while (1) {} >> } >> ------------------------------------------------ >> >> >> >> Richard R. Pope wrote 2014-07-19 20:27: >>> Jan-Erik, >>> I forgot something. Now that it compiles with no errors and jus= t >>> the warning that the paid for version will make smaller code how do I >>> use the interrupt code? I.E. Where do I put this: >>> >>> void Interrupt(){ >>> if (PIR1bits.TMR1IF){ >>> PIR1bits.TMR1IF =3D 0; >>> TMR1H =3D 0x0B; >>> TMR1L =3D 0xDC; >>> //Enter your code here >>> } >>> } >>> >>> Thanks, >>> rich! >>> >>> On 7/19/2014 1:10 PM, Jan-Erik Soderholm wrote: >>>> Either: >>>> >>>> PIR1bits.TMR1IF =3D 0; >>>> >>>> or simply: >>>> >>>> TMR1IF =3D 0; >>>> >>>> The bit struct definition is on the register >>>> level (PIR1), not on the bit level (TMR1IF). >>>> >>>> Jan-Erik. >>>> >>>> >>>> >>>> >>>> Richard R. Pope wrote 2014-07-19 19:40: >>>>> Allan, >>>>> I'm using the MicroChip XC8 compiler. I just looked through= the >>>>> macros in the pic16f684 include file and the code should work. Would = you >>>>> please take a look at this code section? The values that are being >>>>> flagged are the TMR1IF_bit and TMR1IE_bit definitions. Here is the co= de >>>>> with the flagged sections commented out: >>>>> >>>>> void InitTimer1(){ >>>>> T1CON =3D 0x31; >>>>> PIR1bits.TMR1IF =3D 0; >>>>> TMR1H =3D 0x0B; >>>>> TMR1L =3D 0xDC; >>>>> TMR1IE =3D 1; >>>>> INTCON =3D 0xC0; >>>>> } >>>>> >>>>> I can't see what is wrong as these definitions are in the = include >>>>> file. With these statements commented out the code compiles. >>>>> Thanks, >>>>> rich! >>>>> > --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .