dmx.s
changeset 62 2d68a76322cb
parent 46 ffb0c3ec9bc0
equal deleted inserted replaced
61:a960cf5981f7 62:2d68a76322cb
    47 .set DMX_TIMER_WGM_10 = 0b10        ; CTC
    47 .set DMX_TIMER_WGM_10 = 0b10        ; CTC
    48 .set DMX_TIMER_WGM_2 = 0b0
    48 .set DMX_TIMER_WGM_2 = 0b0
    49 
    49 
    50 ; Clock select
    50 ; Clock select
    51 .set DMX_TIMER_CS_STOP = 0b000
    51 .set DMX_TIMER_CS_STOP = 0b000
    52 ;.set DMX_TIMER_CS = 0b001      ; 1/1
    52 .set DMX_TIMER_CS = 0b001      ; 1/1
    53 .set DMX_TIMER_CS = 0b111       ; 1/1024
    53 ;.set DMX_TIMER_CS = 0b111       ; 1/1024
    54 
    54 
    55 ; Counted value
    55 ; Counted value
    56 .set DMX_TIMER_TOP = DMX_CYCLES     ; number of cycles for baud
    56 .set DMX_TIMER_TOP = DMX_CYCLES     ; number of cycles for baud
    57 
    57 
    58 ;; Debug LED
    58 ;; Debug LED
    59 .set LED_DDR = DDRB
    59 .set LED_DDR = DDRB
    60 .set LED_PORT = PORTB
    60 .set LED_PORT = PORTB
    61 .set LED_PIN = PINB
    61 .set LED_PIN = PINB
    62 .set LED_BIT = PORTB5
    62 .set LED_BIT = PORTB0
    63 
    63 
    64 ;; Set up DMX output
    64 ;; Set up DMX output
    65 DMX_Init:
    65 DMX_Init:
    66     ; Setup output port
    66     ; Setup output port
    67         ; out
    67         ; out
   143 _dmx_bit_wait:
   143 _dmx_bit_wait:
   144         ; test OCA hit
   144         ; test OCA hit
   145         sbic    TIFR2, OCF2A     
   145         sbic    TIFR2, OCF2A     
   146         rjmp    _dmx_bit_wait   
   146         rjmp    _dmx_bit_wait   
   147 
   147 
   148 sbi         LED_PIN, LED_BIT
   148 ;sbi         LED_PORT, LED_BIT
   149 
   149 
   150     ; Output bit
   150     ; Output bit
   151         ; XXX: ugly bit-testing, can't we do this using something more nifty?
   151         ; XXX: ugly bit-testing, can't we do this using something more nifty?
   152         brcs    _dmx_bit_1
   152         brcs    _dmx_bit_1
   153         
   153         
   248 		poke		[SPL, r16:r17, RAMEND]
   248 		poke		[SPL, r16:r17, RAMEND]
   249 
   249 
   250     ; Init
   250     ; Init
   251         rcall       DMX_Init
   251         rcall       DMX_Init
   252 
   252 
   253 sbi         LED_PORT, LED_BIT
   253 cbi         LED_PORT, LED_BIT
   254 
   254 
   255     ; Send; value
   255     ; Send; value
   256 _main_loop:
   256 _main_loop:
   257         ldi         r17, 255
   257         ldi         r17, 255
   258         rcall       DMX_Flood
   258         rcall       DMX_Flood
   259 
   259 
   260 ;sbi         LED_PORT, LED_BIT
   260 cbi         LED_PORT, LED_BIT
   261 
   261 
   262         ; never returns..
   262         ; never returns..
   263         rjmp        _main_loop
   263         rjmp        _main_loop
   264 
   264