{{ ************************************ * demo_repeat_blink_led * * 2008 Michael St.Onge * ************************************ Goal: Make a speaker output sound. Purpose: This will demonstrate simple frequency generation by sending pulses at a constant rate. }} CON _clkmode = xtal1 + pll16x ' Feedback and PLL multiplier _xinfreq = 5_000_000 ' External oscillator = 5 MHz pinSpeaker = 0 ' assign which pin the led is on PUB FreqGen ' Main method dira[pinSpeaker]~~ ' Set pin to output (~ sets I/O to input and ~~ sets I/O to output, all pins default to input state) repeat ' Endless loop !outa[pinSpeaker] 'toggles output of pin low/high (if low, then high, or if high, then low) waitcnt(clkfreq / 4 + cnt) ' Wait 1/4 second -> 2 Hz (uses the clock frequency of 5 MHz)