Reynolds Electronics was nice in breaking it down but it won't give me a low enough frequency with the lowest value being 3.9kHz with a 4MHz clock - I need at least 325Hz. I don't really want to change the clock frequency since it affects the speed of my main program. I have posted my code below. It turns an LED on for 1 second and then off for one second while continually sending 3.9kH to a pin. Everyone helps is very much appreciated.
'device PIC12F683
DEFINE LOADER_USED 1'Setup for boot-loader programming
OSCCON = %01100101 ' 01100101 - 4MHZ system clock
TRISIO.2 = 0 ' GPIO.2 (GPIO.2 = Output)
PR2 = 254 '(Max Value = 255 Set PWM Period for approximately 3.9KHz
CCPR1L = 127 ' Set PWM Duty-Cycle to 50%
CCP1CON = %00001100 ' Select PWM Mode
T2CON = %00000100 ' Timer2 = ON + 1:1 prescale
TRISIO.1 = 0
LED_HIGH VAR BYTE
LED_LOW VAR BYTE
BEGIN:
FOR LED_HIGH = 0 TO 10 'Turn ON LED for 1 Second
HIGH GPIO.5
PAUSE 100
NEXT
for LED_LOW = 0 to 10 'Turn OFF LED for 1 Second
LOW GPIO.5
PAUSE 100
Next
GOTO BEGIN
Bookmarks