PWM FOR PIC12F675

Started by vaishnavi236 February 18, 2004
FOR PWM



PLEASE SEND ME UR SUGGESTIONS REGARDING THESE PROGRAMS

REGARDS,
VAISHNAVI
First, use f675temp.asm & PIC12f675.inc (included with mplab) to get
started. This will give you a working baseline. Read the template
file and understand the sections in there. Delete what you do not
need.

You need to watch your register names and goto tags spelling. See
below...

Look in Microhip document DS33023A - PICMicro Mid-Range MCU Family
Reference Manual. Section 11.6.2, Example 11-3, page 11-9 for example
of using TMR0 and Section 12.11, Example 12-4, page 12-10 for example
of using TMR1.

Using the template file, code your application and try assembling
it. The assembler will point out these (and other) errors. Of
course even when it assembles OK does not mean the program will work
as intended. Then the real debugging begins.

pr


--- In , "vaishnavi236" <vaishnavi236@y...>
wrote:
> FOR PWM
>
>
> OPTION equ 81h
> INTCON equ 0bh
> TMR equ 01h

is TMR0 (zero on the end)

> Bcf OPTION ,5 ; TOCS TMR0 CLOCK SOURCE SELECT
> ; 0=> INTERNAL INSTRUCTION CYCLE CLOCK
> bsf OPTION ,3 ; PSA PRESCALER ASSIGNMENT 0=> IS ASSIGNED TO WDT

OPTION,3 = 1 = prescaller assigned to WDT, = 0 = assigned to TMR0

>
> movlw ; I HAVE NOT YET CALCULATED THE VALUE TO
> BE FED
> ; TO TIMER
> movwf TMR0

you defined it as TMR so TMR0 does not exist. Use the include file
to provide names and assignments for all the registers and bits.

> bcf INTCON,2 ; clear TMR 0 overflow indication
> ; TOIF 1=TMR0 REG HAS OVERFLOWED & 0=DID
> NOT
> TMR0: BTFSS INTCON,2 ;BIT TEST F ,SKIP IF SET

Should not use register name for a goto tag

> GOTO TMRO

I see TMRO ( that is the letter O on the end and not the numeral zero,
so this does not exist.)

> Bcf INTCON,2

> TMR1L equ 0Eh
> TMR1H equ 0Fh
> PIE 1 equ 8Ch
> T1CON equ 10h
> PIR1 equ 0Ch
> Clrf TMR1L
> Clrf TMR1H
> Bcf PIR1,0 ; TMR1F TMR1 OVERFLOW INTERRUPT FLAG
> Bsf PIE 1,0 ; TMR1E TMR1 OVERFLOW INTERRUPT ENABLE BIT
> Bsf INTCON,6 ; PEIE peripheral interrupt enable bit
> Bsf INTCON,7 ; GIE global interrupt enable bit

I don't think you need to enable interrupts to have the flag bit work.

> Bcf T1CON,0 ; STOP TIMER 1

I would stop the timer first before writting any of it registers

> Movlw ; I have not yet calculated the values to be put in
> the timer
> Movwf TMR1L
> Movlw
> Movwf TMR1H
> Bsf T1CON,1
> Movlw
> Movwf T1CON
> TMR 1: BTFSS PIR 1,0
> GOTO TMR1
> Bcf PIR 1,0
>
>
> PLEASE SEND ME UR SUGGESTIONS REGARDING THESE PROGRAMS
>
> REGARDS,
> VAISHNAVI
hello,
THANK YOU SIR FOR TELLING ME THE PROCEDURE TO check the pgm i
have written the adc pgm accordingly