AVR Assembler Source Blog

Ремонт частотных преобразователей AVR Assembler Source Blog: Triangle_generator

Saturday, October 5, 2013

Triangle_generator

ремонт устройств плавного пуска
                              ; **************************************************************
                              ; * R/2R-Network produces a triangle signal on Port D          *
                              ; * (C)2005 by http://www.avr-asm-tutorial.net                 *
                              ; **************************************************************

.INCLUDE "8515def.inc"
                              ;
                              ; Register definitions
                              ;
.DEF rmp=R16                  ; Multipurpose register
.DEF rdl=R17                  ; Delay counter

                              ; Constants

.EQU maxAmp=127               ; Maximum amplitude setting
.EQU delay=1                  ; Delay, higher value causes lower frequency

                              ; Main program start

       ldi rmp,0xFF           ; Set all pins of Port D as output
       out DDRD,rmp
triangle:
       clr rmp
loopup:
       out PORTD,rmp          ; to port
       ldi rdl,delay
delayup:
       dec rdl
       brne delayup
       inc rmp                ; next higher value
       cpi rmp,maxAmp
       brcs loopup
loopdwn:
       out PORTD,rmp
       ldi rdl,delay
delaydwn:
       dec rdl
       brne delaydwn
       dec rmp
       brne loopdwn
       rjmp triangle          ; and again forever

No comments:

Post a Comment