Eric, I don't know which pic you are using, but you should be able to run Timer0 (I think) to generate an interrupt whenever your output has to change from high to low. This means that your frequency generating code will run in the background, driven by the interrupt, leaving you clear to run your other code in the foreground. Otherwise you are probably looking at implementing a phase locked loop to be able to multiply the frequency, which gets a little tricky. Your interrupt routine would basically do the following: 1. Save registers etc. 2. Change output state of pin to generate frequency. 3. Reset interrupt flag(s) 4. Reset timer0 so that it will generate the next interrupt when the signal needs to change again 5. Restore registers etc 6. Return Steps 2 to 4 can be shuffled to suit you. Perhaps put step 4 where step 2 is - makes timing easier to calculate. Using the interrupt has the advantage that you don't have to 'tune' your code to achieve the correct delay - only the interrupt routine. You should be able to get within 1 clock cycle of the required delay. The only limitation is that the interrupt routine should be finished by the time the next interrupt occurs. Hope that helps (scream if you need more info) Cheers Roland -----Original Message----- From: erik To: PICLIST@MITVMA.MIT.EDU Date: 09 May 1999 19:14 Subject: Frequency Multiplier >Hello all. > >I'm working on a project where I'm simulating a machine that we are >collecting a bunch of data from. > >The little gadget would have to be configurable via switches to output a >50% duty cycle pulse at various >frequencies. >The maximum frequency would be about 71kHz. That means that I must >evaluate the configuration switches, >check a timer/counter, and turn on an output, plus execute the rest of >the program in about 72 instructions. >(that's if there are no jumps or gotos) > >It's becoming pretty clear that I just won't be able to do it. > >This output is to simulate an encoder and all other outputs must be "in >tune" with this encoder (machine speed) This requirment would seem to >rule out using 1 microcontroller for the encoder signals and another for >the rest. > >So, If I was to give an output pulse at say, 1/10th of the desired >frequency, is there a frequency multiplier of some sort that I could use >for an application like this? I'd like the PIC to output a 7.1kHz pulse, >and do a bunch of other neat stuff, and use another IC or circuit to >multiply the 7.1kHz signal by 10. > >Erik >