;******************************************************************************* ; Title: Dimmer for ARNE-network ; Author: Anders Runeson, arune@users.sf.net ; Version: 1.0.0 ; Date: 2003-02-16 ; ; Target: AT90Sxxxx (All AVR Devices) ; ; DESCRIPTION ; ; The timing is adapted for 4 MHz crystal ; ; Usage: ; ; ;******************************************************************************* ;macbeth test-data: ; ; ; ; ;Senaste ändringar: ;Att göra: ;kunna hämta highlimit-lowlimit från extern nod ;Möjliga fel: ;Fixade fel? .include "2313def.inc" ;***** Pin definitions ;.equ ARNEline =PD2 ;ARNE bus is on PD2, (defined in inc file) ;input .equ ZeroCross =PD3 ;output .equ TriacOutp =PB3 ;***** Global register variables ;**Regs 0 to 15 cannot handle SBCI, SUBI, CPI, ANDI, ORI, LDI, SER, SBR, CBR .def eepromRxTx =R7 .def gotovalue =R8 ;** .def temp =R17 ;Arne need a temp reg .def parsertemp =R22 .def DimStrength =R23 .def statusreg =R24 .def temp2 =R25 ;.def eepromadress =R23 ;.def bitcnt =R24 ;arne_dedi_nr_of_bytes is DEDICATED R2, this reg contains the number of bytes recieved ;ARNE STATUS REG IS DEDICATED, R16 ;arne_dedi_cnt is DEDICATED, R18 ;See ARNEroutines.asm for more registers (these are probably put on stack when using bus => no worries using them) ;***** Other .equ xtal =4000000 .equ bus_freq =80000 .equ this_node_adress =0x75 ;Reserved adress (maybe) 0x00 and 0xFF? ;.equ this_node_type =25 ;En lista över typer av noder? ;define where arne_data is stored in sram (moved elsewhere is untested) .equ Start_of_Data_To_Send =0x60 .equ Start_of_Recieved_Data =0x71 .equ LOWLIMITDIM =0 .equ HIGHLIMITDIM =133 ;79 ;den får inte vara nära 255 .equ ABSADDVALUE =1 .equ ABSADDVALUE_FAST =4 ;dessa hör till statusreg .equ BITPOS =0 ; bitpos är för öka ljusstyrkan .equ BITNEG =1 ; bitneg minska .equ BITFAST =2 .MACRO mac_arne_send_todo .ENDMACRO .MACRO mac_arne_recieve_todo .ENDMACRO .include "..\AssemblerSource\ARNEroutines.asm" ;############################################################# ;# RESET # ;############################################################# ;interrupt vectors .ORG 0x00 rjmp RESET ;Reset Handler .ORG INT0addr rjmp arne_EXT_INT0 ;IRQ0 Handler, Om det händer något på ben 6 (PD2) .ORG INT1addr rjmp EXT_INT1 ;IRQ1 Handler .ORG OVF1addr rjmp OVFL_TIM1 ;Timer1 Overflow handler .ORG OVF0addr rjmp arne_TIM_OVF0 ;Timer0 Overflow 8 bit RESET: cli ;############################################################# ;# INIT # ;############################################################# ;INIT STACKPOINTER ldi temp,low(RAMEND) out SPL,temp ;INIT PORT D ;arne line cbi DDRD,ZeroCross ;ZeroCross-mod is input sbi PORTD,ZeroCross ;use pullup ;INIT PORT B sbi DDRB,TriacOutp ;output cbi PORTB,TriacOutp ;INIT INTERRUPT ldi temp,0b00001100 ;Setup Interrupt Sense Control for trigging on rising edge out MCUCR,temp ldi temp,(1<