Are the two fequencies always a factor of 2X apart? (10kHz and 20kHz)
What else does this PIC need to do?
Do the two PWM need to be in phase?
Are the two fequencies always a factor of 2X apart? (10kHz and 20kHz)
What else does this PIC need to do?
Do the two PWM need to be in phase?
Paul Borgmeier
Salt Lake City, UT
USA
__________________
PWM and maybe a programmable divider OR a divider and a MUX to select the appropriate frequency multiple.
Whats your application btw please??
Thank you guys.
I got the following clever code from MeLabs support, that solves my problem. It produce simultaneous frequencies of 20KHz, 10KHz, and 5KHz:
DEFINE OSC 20 ' Use a 20MHz crystal for best results
freq_delay VAR WORD
freq_delay = 25 ' 25uS for 20KHz top frequency ((1/20K)/2)
TRISB = %11111000 ' freq pins to outputs
' Output 20KHz on RB0, 10KHz on RB1, 5KHz on RB2
' Adjust freq_delay to compensate for loop overhead
loop:
PAUSEUS freq_delay
PORTB = (PORTB & %00000111) + 1 ' count binary 000 to 111
GOTO loop
Bookmarks