Tom Wrighton wrote: > I'm a newbie, hobbyist, nonprofessional and retired. OK, but you can still write your posts single spaced. Your double spaced post was annoying to read since it effectively shrunk my screen window by 2. > I'm trying to use the internal RC osc > > ( _INTRC_OSC_NOCLKOUT ) which I believe ends up at 1 us > > execution cycles. Yes. > To achieve a 38KHz flash rate I need an interrupt > every > > 26.3 us. This calculates to loading the TMR0 with something like There are several ways to do this. Taking an interrupt every half cycle is probably not the best. I've driven IR LEDs at 40KHz with similar chips, and did the timing in line. Shut off interupts and count cycles. With a little assembler math, you can have it insert the right numbers of NOPs at the right places for you. Another possibility is to use timer 0 but with software polling. This gives you 3 cycles of jitter, which you can eliminate with a short jump table into a string of NOPs. Or not. Maybe some jitter is acceptable. Here is some code that runs on a 10F202 that uses software polling and de-jittering of timer 0 for each half cycle: ;*********************************************************************** ; ; Subroutine IR_ON ; ; Emit infrared output via the infrared LEDs for the next REG0 carrier ; pulses. The carrier pulse is emitted a consistant delay after timer ; 0 wraps from 255 to 0. Timer 0 is adjusted so that it will next wrap ; one IR carrier cycle later. ; ; REG0 is trashed. ; ir_on iron_loop ;back here each new carrier pulse btfsc tmr0, 7 ;wait for timer 0 wrap goto $-1 ; ; TMR0 is now either 2, 3, or 4, depending on where within the wait loop ; timer 0 wrapped from 255 to 0. The add to PCL here removes this jitter. ; movf tmr0, w ;get either 3, 4, or 5 addwf pcl nop nop nop nop ;3 nop ;4 ; ; An IR carrier cycle starts right now. Instruction timing jitter has ; been removed. ; ir_swon ;IR emitter switched on here bsf ir_pin ;turn on the IR emitter movlw irt0inc addwf tmr0 ;update timer 0 for next carrier cycle start ii set $ - ir_swon ;make number of cycles emitter on so far if ii > ironcy error IR emitter on for too many cycles endif waitnop ironcy - ii ;fill in cycles until switch of IR emitter bcf ir_pin ;turn off the IR emitter decfsz reg0 ;count one less IR carrier pulse left to emit jump iron_loop ;back to do next pulse retlw 0 ;done with all requested pulses ***************************************************************** Embed Inc, embedded system specialists in Littleton Massachusetts (978) 742-9014, http://www.embedinc.com -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist