Hello,
Thanks to all, it works fine now.
We made the next loop with a led, just for testing!
@ DEVICE PIC16F819,INTRC_OSC_NOCLKOUT
@ DEVICE CCPMX_ON ' RB3 PWM
@ DEVICE PIC16F819,MCLR_OFF
OSCCON =$60 ' 4 MHz
DEFINE CCP1_REG PORTB
DEFINE CCP1_BIT 3
PR2 =249 ' Set PR2 to get 1kHz out
T2CON =%00000100 ' Values for PWM period
CCP1CON =%00001100 ' Set PWM Mode
ADCON1 =%00001110 ' 0=analog, 1,2,3,4=digital
TRISA =%11111111
TRISB =%00000000
PORTB =%00000000
n VAR WORD
'=====
BEGIN:
For n=1 TO 1023 STEP 4
GoSub loop
Pause 10
Next
For n=1023 TO 1 STEP -4
GoSub loop
Pause 10
Next
GoTo BEGIN
loop:
T2CON=%00000101 ' Turn on Timer2, Prescaler=4
CCP1CON.4 =n.0 ' Store n to registers as
CCP1CON.5 =n.1 ' a 10-bit word
CCPR1L =n>>2
Return
Thanks all,
Peter
Bookmarks