;######################################################## ;# Projekt: # ;# Drehencoder Auswertung # ;# mit Timer # ;# oder # ;# mit INT0/1 Drehnencoder & PCI Taster # ;# # ;# Timer Zeilen mit * aktivieren & ** deaktivieren # ;# Interrupts Zeilen mit * deaktvieren & ** aktivieren # ;# # ;# Taktfrequenz des AVR: 16 MHz # ;# # ;# CS-SOFT # ;######################################################## .include "m328Pdef.inc" ;AtmegaNN8 .def math1h = r8 .def math1l = r9 .def math2h = R10 .def math2l = r11 .def matherghh = r12 .def mathergh = r13 .def mathergl = r14 .def mathergll = r15 .def temp0 = r16 ; .def temp1 = r17 ; .def temp2 = r18 .def temp3 = r19 ; .def temp4 = r20 .def cnt = r21 .equ cpu = 16000000 .equ Baud0 = 9600 .equ UBRR0 = cpu/(16*Baud0)-1 ;**********LCD Port mit 74HC164 .equ LCD_signs = 20 .equ Zeile1 = $00+$80 .equ Zeile2 = $40+$80 .equ Zeile3 = Zeile1+LCD_signs .equ Zeile4 = Zeile2+LCD_signs .equ port_lcd_x = portc ;gilt für 4/8bit modus .equ ddrx_lcd_x = ddrc ; Pinbelegungen ; STD .equ SClock = 0 ;LCD ;;; .equ SRS = 0 .equ SData = 1 ;74164 ;;;;;so Kann die HW angeschlossen sein .equ SRW = 1 .equ Light = 2 ;LCD ;;;;; .equ SEnable = 3 ;74164 ;;; ;********* parallel für LCD/Simulationssoftware************* ;.equ st_port_lcd_x = portb ;.equ st_ddrx_lcd_x = ddrb ; STD .equ PRS = 4 ; .equ PEnable = 5 ; ;Entry Set .equ SH = 0 ;1 = Display shift 0 = not shifted .equ ID = 1 ;1 = increase 0 = decrease .equ HES = 2 ;immer 1 setzen Symbolisiert das Ende ;des Commandos ;DISPLAY on/off .equ B = 0 ;1 = Blink 0 = no Blink .equ C = 1 ;1 = Cursor on 0 = Cursor off .equ D = 2 ;1 = Disp on 0 = Disp off .equ HD = 3 ;immer 1 setzen Symbolisiert das Ende ;des Commandos ;Shift .equ RL = 2 ;1 = right shift 0 = left shift .equ SC = 3 ;1 = Disp shift 0 = Cursor move .equ HS = 4 ;immer 1 setzen Symbolisiert das Ende ;des Commandos ;SET Function .equ F = 2 ;1 = 5x10 0 = 5x7 .equ N = 3 ;1 = 2line(4line) 0 = 1line .equ DL = 4 ;1 = 8bit int 0 = 4bit interface .equ HSF = 5 ;immer 1 setzen Symbolisiert das Ende ;des Commandos ;************ Drehencoder Zuordnung************ .equ DrehENC_ddr = ddrD .equ DrehENC_port= Portd .equ DrehENC_pin = Pind .equ Phase_A = 2 .equ Phase_B = 3 .equ Taster_ENC = 4 ;**********interner ADC .equ ADC_ddr = ddrc .equ ADC_Port = Portc .equ ADC_Pin = PinC .equ Chan0 = 0 .equ Chan1 = 1 .equ Chan2 = 2 .equ Chan3 = 3 .equ Chan4 = 4 .equ Chan5 = 5 .equ ref5 = $1312 .equ ref52 = $0 .equ ref256 = $09d0 .equ ref2562 = $0 ;**********SRAM .equ erg_k = $0100 ;erg_k wird bis zu 5 weiteren bytes genutzt sprich erg_k+5 .equ ocra0 = $0105 ;für T0 .equ ocrb0 = $0106 .equ ocra1h = $0107 ;;;;; .equ ocra1l = $0108 ;;;;;;;; für T1 A channel .equ ocrb1h = $0109 ;;;;; .equ ocrb1l = $010a ;;;;;;;; für T1 B channel .equ icr1xh = $010b ;;;;; .equ icr1xl = $010c ;;;;;;;; für T1 ICR .equ ocra2 = $010d .equ ocrb2 = $010e .equ hadc = $0110 ;adc .equ ladc = $0111 ;adc .equ eep_adrh = $0112 ;eeprom .equ eep_adrl = $0113 ;eeprom .equ LTC_wertH = $0114 .equ LTC_wertL = $0115 .equ dreh_ENC_old= $0116 .equ dreh_Richt = $0117 .equ dreh_tast_old = $0118 .equ RSdebug = $0140 ;debug serielle Schnittstelle ;***************************Einsprungadressen*********************** .cseg .org $0000 rjmp stack .org $0002 ;2 rjmp INT_EX0 ;** .org $0004 ;4 rjmp INT_EX1 ;** .org $0006 ;6 reti;rjmp INT_PC0 .org $0008 ;8 reti;rjmp INT_PC1 .org $000a ;a rjmp INT_PC2 ;** .org $000c ;c reti;rjmp INT_WDT .org $000e ;e reti;rjmp INT_OC2A .org $0010 ;10 reti;rjmp INT_OC2B .org $0012 ;12 reti;rjmp INT_OVF2 .org $0014 ;14 reti;rjmp INT_CPT1 .org $0016 ;16 reti;rjmp INT_OC1A .org $0018 ;18 reti;rjmp INT_OC1B .org $001a ;1a reti;rjmp INT_OVF1 .org $001c ;1c ;reti rjmp INT_OC0A .org $001e ;1e reti;rjmp INT_OC0B .org $0020 ;20 reti;rjmp INT_OVF0 .org $0022 ;22 reti;rjmp INT_SPI .org $0024 ;24 reti;rjmp INT_USART_RX .org $0026 ;26 reti;rjmp INT_USART_UDRE .org $0028 ;28 reti;rjmp INT_USART_TX .org $002a ;2a reti;rjmp INT_ADC .org $002c ;2c reti;rjmp INT_EE_Ready .org $002e ;2e reti;rjmp INT_ANALOG_COMP reti ;11 keine 2wireRoutinen reti ;a keine SPI Routinen ;***************************Init mit allem drumdran***************** stack: ldi temp1,high(ramend) ;Stackpointer festlegen out sph, temp1 ldi temp1,low(ramend) ;Stackpointer festlegen out spl, temp1 rcall sram ; rcall lcd_init ; rcall lcd_clear ; rcall werbe1 ; rcall werbe2 ; rcall wait1s ; rcall leer_z ; rcall INIT_ext_Int01 ; rcall deak_int01 ; rcall INIT_PC_INTx ; rcall mode7_t0_init ; rcall prescaler_T0_on ; rcall mode4_t1_init ; rcall prescaler_T1_on ; rcall mode2_t2_init ; rcall prescaler_T2_on ; rcall adc_header ; rcall eeprom_init ;wenn ints bevorzugt werden ; rcall adr_cnt ; rcall eeprom_write ; rcall AC_init ; rcall ac_change ; rcall usart_init ;wenn INT bevorzugt dann hier aktivieren und prog erweitern ; rcall werbe_rs rcall init_DrehEncoder start: nop nop nop nop nop nop nop nop nop nop nop nop nop nop rjmp start ;*********Sram clearen*********************************************** sram: clr temp0 ldi yl,low(SRAM_START) ldi yh,high(SRAM_START) ;Masterclr des Sram's über sram2: st y+,temp0 ;die indirekte Adressierung cpi yl,$50 ;bis zur zelle x=$a0 löschen brne sram2 ret ;*************************weitere*includedata*********************** ;.include "AtMega328_adc_lst.asm" ;.include "AtMega328_analogcomparator.asm" .include "AtMega328_ext_ints.asm" ;.include "AtMega328_eeprom.asm" .include "AtMega328_timercounter.asm" ;.include "AtMega328_uart_std.asm" ;.include "AtMega328_LCD_Txt_out.asm" ;.include "AtMega328_RS_Txt_out.asm" ;.include "h:\etronik\Software3\sonstiges\origin\mathe.asm" ;.include "i:\etronik\Software3\sonstiges\origin\lcd_KS0066_KS0070_8bit.asm" ;.include "h:\etronik\Software3\sonstiges\origin\lcd_KS0066_KS0070_4bit_HapSim.asm" ;Nur zur Simulation mit HapSim aktivieren ;.include "h:\etronik\Software3\sonstiges\origin\zeitschleifen.asm" ;.include "h:\etronik\Software3\sonstiges\origin\hex_dez_wandlung.asm" ;gebraucht für LCD oder nur umwandlung .include "h:\etronik\Software3\sonstiges\origin\DrehEncoder.asm" ;*************************ENDE**************************************