Forum: Mikrocontroller und Digitale Elektronik PWM


PWM
von Anja (Gast)


Lesenswert?

Hi

Kennt jemand Schaltungen zur PWM-Signalerzeugung mit AVRs (Bitte mit 
Sourcecode)
Danke

Anja

: Gesperrt durch Moderator
von Oliver Hanka (Gast)


Lesenswert?

Den Sourcecode hab ich irgendwo im web gefunden..

Gruß
  Olli


;**********************************
;PWM.ASM
;this is a very simple program
;which write a value from the
;register: pwm, to the pwm pin PD5.
;**********************************

.include  "c:\avrtools\appnotes\8515def.inc"

.def  temp = r16
.def  pwm = r17

.cseg
.org  $000
  rjmp  reset      ;reset handle

reset:  rjmp  init      ;start init

init:  ldi  temp,ramend
  out  spl,temp    ;set spl
  ldi  temp,high(ramend)
  out  sph,temp    ;set sph

  ldi  temp,0b11111111    ;portb = output
  out  ddrd,temp

  out  portb,temp    ;switch led's off

  ldi  temp,0b10000001    ;init PWM... (choose 8-Bit PWM etc...)
  out  tccr1a,temp

  ldi  temp,0
  out  ocr1ah,temp

  ldi  temp,1
  out  ocr1al,temp

  ldi  temp,0b00000001
  out  tccr1b,temp

  sei        ;enable interrupts

  rjmp  loop

loop:  ldi  pwm,230      ;choose the value for pwm
  out  ocr1al,pwm
  rjmp  loop

von Andreas S. (andreas) (Admin) Benutzerseite


Lesenswert?

Anja schrieb:
> Kennt jemand Schaltungen zur PWM-Signalerzeugung mit AVRs
> (Bitte mit Sourcecode)

http://www3.igalaxy.net/~jackt/analog.htm

MfG
Andreas

Dieser Beitrag ist gesperrt und kann nicht beantwortet werden.