Exact match. Not showing close matches.
PICList
Thread
'[PIC] Simple 16C73 PWM routine?'
2000\05\19@102116
by
Graham North
Hi
I am just starting to play with the 16C73, and would like to use the PWM
outputs.
I have read the data book but I am afraid it has gone straight over my head
(I have
not implemented any PWM outputs before).
If anyone has a simple program to get me started I would be very grateful.
Thanks
Graham
(I just don't know where to start!)
2000\05\19@104424
by
Ismael M. Khangane
Hi Graham:
In which programming language? Asm or C?
Ismael.
Graham North wrote:
{Quote hidden}> Hi
>
> I am just starting to play with the 16C73, and would like to use the PWM
> outputs.
> I have read the data book but I am afraid it has gone straight over my head
> (I have
> not implemented any PWM outputs before).
>
> If anyone has a simple program to get me started I would be very grateful.
>
> Thanks
>
> Graham
>
> (I just don't know where to start!)
--
------------------------------------------------------------------
Ismael M. Khangane, Specialist in Robotics. Automatic Control & Systems ( Bsc
in Eng.)
Instituto de Automatica Industrial IAI-CSIC
Madrid, Spain.
Tel: (34) 91 871 1900
Fax: (34) 91 871 7050
E-mail: spam_OUTimkespTakeThisOuT
excite.com ; .....ismaelmKILLspam
@spam@iai.csic.es
------------------------------------------------------------------
2000\05\19@113614
by
Matt Sidare
Graham,
Here's a short bit of code that sets up the PWM and sets the PWM to ~50%
duty cycle
I copied it from some code that works, Its been a while since I wrote it
so,
I may have forgot to copy something. Try it and let us know.
MOVLW 0xFF ; 00 --> W
BSF STATUS, RP0 ; Select bank 1
MOVWF PR2 ; Load PR2 with period info
; at 20MHz PR2=FF gives a 1.22KHz
; at 4MHz PR2=FF gives a 3.906KHz
BCF STATUS, RP0 ; Select bank 0
MOVLW 0X80 ; Load W with 0X80
MOVWF CCPR1L ; Duty Cycle is ~50% of PWM 1 Peroid
MOVWF CCPR2L ; Duty Cycle is ~50% of PWM 2 Peroid
BSF T2CON, T2CKPS1 ; Set the TMR2 prescale value
BSF T2CON, T2CKPS0 ; Set the TMR2 prescale value
BSF T2CON, TMR2ON ; Enable timer2
MOVLW 0X0F ;
MOVWF CCP1CON ; SET low two bits of PWM 1 and turn it on
MOVWF CCP2CON ; SET low two bits of PWM 2 and turn it on
; PWM has 10-bits of resolution
Matt
2000\05\22@040833
by
Graham North
|
Asm if possible.
-----Original Message-----
From: Ismael M. Khangane [SMTP:ismaelm
KILLspamIAI.CSIC.ES]
Sent: 19 May 2000 15:39
To: .....PICLISTKILLspam
.....MITVMA.MIT.EDU
Subject: Re: [PIC] Simple 16C73 PWM routine?
Hi Graham:
In which programming language? Asm or C?
Ismael.
Graham North wrote:
> Hi
>
> I am just starting to play with the 16C73, and would like to use
the PWM
> outputs.
> I have read the data book but I am afraid it has gone straight
over my head
> (I have
> not implemented any PWM outputs before).
>
> If anyone has a simple program to get me started I would be very
grateful.
>
> Thanks
>
> Graham
>
> (I just don't know where to start!)
--
------------------------------------------------------------------
Ismael M. Khangane, Specialist in Robotics. Automatic Control &
Systems ( Bsc
in Eng.)
Instituto de Automatica Industrial IAI-CSIC
Madrid, Spain.
Tel: (34) 91 871 1900
Fax: (34) 91 871 7050
E-mail: EraseMEimkespspam_OUT
TakeThisOuTexcite.com ; ismaelm
spam_OUTiai.csic.es
------------------------------------------------------------------
2000\05\22@051809
by
Graham North
Thanks for the program.
Am I right by looking at the program that the input from the 10k pot should
be connected to RA0?
Which port is the output?
<Snip> BCF TRISC,2 ;MAKE PIN OUTPUT
Is it port C? All 8 leds connected.
Sorry for the dumb questions.
Thanks Graham
-----Original Message-----
From: RAYMOND WILLCOX [SMTP:@spam@markwillcox56KILLspam
hotmail.com]
Sent: 20 May 2000 17:50
To: KILLspamGRAHAM.NORTHKILLspam
LANDINST.COM
Subject: Re: [PIC] Simple 16C73 PWM routine?
Graham
Here is a simple A/D - PWM code (from Toni Nixon), it works well.
It
drives an eight bit bar-graph display or 8 LED's. It uses a 10k pot
on the
input. Real simple and quite self explanitory. Have fun - Mark
2000\05\22@133202
by
Quentin
|
Graham North wrote:
>
> Thanks for the program.
>
> Am I right by looking at the program that the input from the 10k pot should
> be connected to RA0?
>
> Which port is the output?
>
> <Snip> BCF TRISC,2 ;MAKE PIN OUTPUT
>
> Is it port C? All 8 leds connected.
>
> Sorry for the dumb questions.
>
> Thanks Graham
Graham, there are no such thing as dumb questions, only dumb answers. I
am not referring to the other replies to your email of course :).
I did not see the program that Tony wrote, but it should be very similar
to this A/D to PWM test program below (I modified the tutorial A/D
program for the ICD, bit rough, but it works).
To answer your questions: The 10K pot is connected to RA0 and the pin is
set up to be an analogue input. BCF TRISC,2 is the CCP1 output on PortC
which is set up to be the PWM1 output.
Get the Mid-Range MCU Family Reference Manual from Microchip. It will
give you a bit more info (You can also get it from Microchip's web with
each chapter as a separate download, get the CCP section).
To do PWM:
Set up TMR2, switch TMR on and set prescaler (16 in this case).
Set TMR2 period in PR2. Default is 0x0FF. You should only change this
setting lower if you want a faster PWM period (together with the
prescaler), but then you start meddling with resolution.
Clear TMR2 interupts in PIR2 and PIE2 (You don't need them for simple
PWM) Should be cleared as default.
Do the calculations (in the data books) to see if your duty cycle is not
longer than the period. The above settings should keep you in spec.
Set CCP1CON to be PWM.
Write your PWM duty cycle to CCPR1L (8 MSB) and CCP1CON, 5 and 4 (2 LSB)
and away you go!
Hope this helps
Quentin
;A/D input on RA0 to PWM output on RC2
Start
banksel PORTC
clrf PORTC ;Clear PORTC
movlw B'01000001' ;Fosc/8, A/D enabled
movwf ADCON0
banksel OPTION_REG
movlw B'10000111' ;TMR0 prescaler, 1:256
movwf OPTION_REG
clrf TRISC ;PORTC all outputs
movlw B'00001110' ;Left justify,1 analog channel
movwf ADCON1 ;VDD and VSS references
banksel PORTC
MOVLW B'00000111' ;switch on TMR2 and set prescaler to 16
MOVWF T2CON
MOVLW B'00001100'
MOVWF CCP1CON ;select CCP1 to be PWM output
Main
btfss INTCON,T0IF ;Wait for Timer0 to timeout
goto Main
bcf INTCON,T0IF
bsf ADCON0,GO ;Start A/D conversion
Wait
btfss PIR1,ADIF ;Wait for conversion to complete
goto Wait
DO_PWM movf ADRESH,W ;Write A/D result to PWM
MOVWF CCPR1L
BCF CCP1CON,4 ;do the LSB
BCF CCP1CON,5
BSF STATUS,RP0
MOVF ADRESL,W
BCF STATUS,RP0
MOVWF TEMP1
BTFSC TEMP1,6
BSF CCP1CON,4
BTFSC TEMP1,7
BSF CCP1CON,5
goto Main ;Do it again
More... (looser matching)
- Last day of these posts
- In 2000
, 2001 only
- Today
- New search...