max0412
Full Member level 5
1.25khz oscillator
This is probably Amusingly simple but I'm just starting out with PIC's. So be kind.
Is it possible to generate a 1.25kHz 50% duty cycle wave from a PIC12F508. I come across examples where they use a NOP for 1uS intervals here.
Is there a simple way to increase the NOP for my required waveform? Or is there an alternative way? I know this can be done with timers and logic but I’d prefer the PIC it lets me adjust the duty cycle with ease.
This is probably Amusingly simple but I'm just starting out with PIC's. So be kind.
Is it possible to generate a 1.25kHz 50% duty cycle wave from a PIC12F508. I come across examples where they use a NOP for 1uS intervals here.
Code:
PROCESSOR 12f508
#include "p12f508.inc"
__CONFIG _MCLRE_OFF & _CP_OFF & _WDT_OFF & _XT_OSC
#DEFINE PORT B'11111101'
MOVF OSCCAL
MOVLW PORT
TRIS GPIO
BEGIN
BCF GPIO, 1 ;1uS
NOP ;2uS each nop is 1uS long
NOP ;3uS
NOP ;4uS
NOP ;5uS
NOP ;6uS
NOP ;7uS
NOP ;8uS
NOP ;9uS
NOP ;10uS
NOP ;11uS
NOP ;12uS
NOP ;13uS
NOP ;14uS
NOP ;15uS
NOP ;16uS
NOP ;17uS
NOP ;18uS
NOP ;19uS
BSF GPIO, 1 ;1uS Begin HIGH duty cycle
NOP ;2uS
NOP ;3uS
NOP ;4uS
NOP ;5uS
GOTO BEGIN ;2uS (26uS total for 38KHz)
END
Is there a simple way to increase the NOP for my required waveform? Or is there an alternative way? I know this can be done with timers and logic but I’d prefer the PIC it lets me adjust the duty cycle with ease.