Visualizza messaggio singolo
Vecchio 15 aprile 11, 12:43   #6 (permalink)  Top
Fantuz92
User
 
Data registr.: 13-04-2011
Messaggi: 9
Ah... qualche giorno fa il prof di sistemi ha trovato un programma con il 16f84a per gnenerare un' onda pwm.



; FILE: PWM.asm
; AUTH: Keith Sevcik
; DATE: 5/21/03
; DESC: This program generates a PWM waveform.
; NOTE: Tested on PIC16F84-04/P

;----------------------------------------------------------------------
; cpu equates (memory map)

list p=16f84
radix hex

;----------------------------------------------------------------------

portb equ 0x06 ; port b equate
duty equ 0x0c ; length of duty cycle
temp equ 0x0d ; length of duty cycle

;---------------------------------------------------------------------

c equ 0 ; status bit to check after subtraction

;---------------------------------------------------------------------

org 0x000

movlw 0x00 ; load W with 0x00 make port B output
tris portb ; copy W tristate to port B outputs
movlw 0x00 ; fill w with zeroes
movwf portb ; set port b outputs to low
rstrt movlw d'0'
movwf portb
movlw d'157' ; Duty cycle length
movwf duty
b0loop movf duty,w
movwf temp
bsf portb,0
pwma nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
decfsz temp
goto pwma
movlw d'255'
movwf temp
movf duty,w
subwf temp,f
bcf portb,0
pwmb nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
decfsz temp
goto pwmb
goto rstrt

;----------------------------------------------------------------------

end

;----------------------------------------------------------------------
; at burn time, select:
; memory uprotected
; watchdog timer disabled
; standard crystal (4 MHz)
; power-up timer on
Fantuz92 non è collegato   Rispondi citando