Blame | Last modification | View Log | Download | RSS feed
ifndef __regavrinc ; avoid multiple inclusion__regavrinc equ 1savelisting off ; no listing over this file;****************************************************************************;* *;* AS 1.42 - Datei REGAVROLD.INC *;* *;* Contains SFR and Bit Definitions for AVR Processors *;* OUTDATED VERSION - PLEASE SWITCH TO NEW FILE IF POSSIBLE *;* *;****************************************************************************; Set internal CPU code and memory addresses in one stepswitch MOMCPUNAMEcase "AT90S1200"__cpucode equ 0x011200eeend equ 63 ; End Address EEPROMiramend equ 95,data ; End Address SRAMiromend label 1023 ; End Address EPROMcase "AT90S2313"__cpucode equ 0x012313eeend equ 127iramend equ 0xdf,datairomend label 2047case "AT90S4414"__cpucode equ 0x014414eeend equ 255iramend equ 0x15f,datairomend label 4095case "AT90S8515"__cpucode equ 0x018515eeend equ 511iramend equ 0x25f,datairomend label 8191case "ATMEGA8"__cpucode equ 0x020008eeend equ 511iramend equ 0x45f,datairomend label 8191case "ATMEGA16"__cpucode equ 0x020010eeend equ 511iramend equ 0x45f,datairomend label 16383elsecasefatal "wrong target selected: only AT90S1200, AT90S2313, AT90S4414, AT90S8515, ATMEGA8, or ATMEGA16 supported"endcaseismega function code,(code>>16)=2if MOMPASS=1message "Atmel AVR SFR Definitions (C) 1996,2002 Alfred Arnold"endif;----------------------------------------------------------------------------; Constant Memory Addresseseestart equ 0 ; Start Address Internal EEPROMiram equ 96,data ; Start Address Internal SRAM; (behind mapped I/O)irom label 0 ; Start Address Internal EPROM;----------------------------------------------------------------------------; Prozessorkernsreg port 0x3f ; Status Register:c equ 0 ; Carryz equ 1 ; Zero Resultn equ 2 ; Negative Resultv equ 3 ; Twos Complement Overflows equ 4 ; Signh equ 5 ; Half Carryt equ 6 ; Bit Storagei equ 7 ; Globale Interrupt Enable; Size of stack pointer depends on size of Internal data space; (if present at all)if __cpucode>=0x012313spl equ 0x3d ; Stack Pointer (LSB)if iramend>=256sph equ 0x3e ; (MSB)endifendif;----------------------------------------------------------------------------; Chip Configurationmcucr port 0x35 ; CPU Control:isc00 equ 0 ; INT0 Edge Selectionisc01 equ 1 ; INT0 Edge/Level Triggerif __cpucode>=0x012313isc10 equ 2 ; INT1 Edge Selectionisc11 equ 3 ; INT1 Edge/Level Triggerendifif ismega(__cpucode); Note: for the Mega16, bits 6 & 7 are interchanged, I guess that's an; error in the data sheet...se equ 7 ; Sleep Enablesm2 equ 6 ; Sleep Mode Selectsm1 equ 5sm0 equ 4else ; !ismegasm equ 4 ; Select Idle/PowerDdown Modese equ 5 ; Enable Sleep Modeif __cpucode>=0x014414srw equ 6 ; Wait State Selection External SRAMsre equ 7 ; External External SRAMendifendifif ismega(__cpucode)osccal port 0x31 ; Oscillator Calibrationmcucsr port 0x34if __cpucode>=0x020010jtd equ 7 ; JTAG Reset Flagisc2 equ 6 ; Interrupt Sense Control 2endifwdrf equ 3 ; Watchdog Reset Occuredborf equ 2 ; Brown Out Occuredextrf equ 1 ; External Reset Occuredporf equ 0 ; Power On Reset Occuredspmcr port 0x37 ; Store Program Memory Control Registerspmie equ 7 ; Interrupt Enablerwwsb equ 6 ; Read-while-Write Section Busyrwwsre equ 4 ; Read-while-Write Section Read Enableblbset equ 3 ; Boot Lock Bit Setpgwrt equ 2 ; Page Writepgers equ 1 ; Page Erasespmen equ 0 ; Store Program Memory Enableendif;----------------------------------------------------------------------------; Interrupt-Steuerungif ismega(__cpucode)gicr port 0x3bivce equ 0 ; Interrupt Vector Change Enableivsel equ 1 ; Interrupt Vector Selectint0 equ 6 ; Enable External Interrupt 0int1 equ 7 ; Enable External Interrupt 1if __cpucode>=0x020010int2 equ 5 ; Enable External Interrupt 2endifelseifgimsk port 0x3b ; Global Interrupt Mask:int0 equ 6 ; External Interrupt 0if __cpucode>=0x012313int1 equ 7 ; External Interrupt 1endifendifif __cpucode>=0x012313gifr port 0x3a ; Global Interrupt Flagsintf0 equ 6 ; External Interrupt 0intf1 equ 7 ; External Interrupt 1ifdef int2intf2 equ int2 ; External Interrupt 2endifendif; who the heck decided to rearrange all bits for the Megas?timsk port 0x39 ; Timer Interrupt Mask:if ismega(__cpucode)toie0 equ 0elseiftoie0 equ 1 ; Timer 0 Overflowendifif __cpucode>=0x012313if __cpucode>=0x014414if ismega(__cpucode)ocie1b equ 3 ; Timer 1 Vergleich Belseifocie1b equ 5 ; Timer 1 Vergleich Bendifendifif ismega(__cpucode)toie1 equ 2ticie1 equ 5toie2 equ 6ocie2 equ 7ocie1a equ 4elseiftoie1 equ 7 ; Timer 1 Overflowticie1 equ 3 ; Timer 1 Captureocie1a equ 6 ; Timer 1 Compareendifendiftifr port 0x38 ; Timer Interrupt Flagstov0 equ toie0 ; Timer 0 Overflowif __cpucode>=0x012313ocf1a equ ocie1a ; Timer 1 Compare Atov1 equ toie1 ; Timer 1 Overflowicf1 equ ticie1 ; Timer 1 Captureendifif __cpucode>=0x014414ocf1b equ ocie1b ; Timer 1 Compareendifif ismega(__cpucode)tov2 equ toie2ocf2 equ ocie2endif;----------------------------------------------------------------------------; Parallel Portsif ismega(__cpucode)sfior equ 0x30psr10 equ 0 ; T0/T1 Prescaler Resetpsr2 equ 1 ; ditto T2pud equ 2 ; Pullup Disableacme equ 3 ; Analog Comparator Multiplexer Enableadhsm equ 4 ; ADC High Speed Modeif __cpucode>=0x020010adts0 equ 5adts1 equ 6adts2 equ 7endifendifif (__cpucode=0x014414)||(__cpucode=0x018515)||(__cpucode=0x020010)porta port 0x1b ; Port A Data Registerddra port 0x1a ; Port A Data Direction Registerpina port 0x19 ; Port A Read Registerendifportb port 0x18 ; Port B Data Registerddrb port 0x17 ; Port B Data Direction Registerpinb port 0x16 ; Port B Read Registerif __cpucode>=0x014414portc port 0x15 ; Port C Data Registerddrc port 0x14 ; Port C Data Direction Registerpinc port 0x13 ; Port C Read Registerendifportd port 0x12 ; Port D Data Registerddrd port 0x11 ; Port D Data Direction Registerpind port 0x10 ; Port D Read Register;----------------------------------------------------------------------------; Timertccr0 port 0x33 ; Timer 0 Control Register:cs00 equ 0 ; Prescaler Settingcs01 equ 1cs02 equ 2if __cpucode=0x020010wgm01 equ 3 ; Waveform Generation Modewgm00 equ 6com00 equ 4 ; Compare/Match Output Modecom01 equ 5foc0 equ 7 ; Force Output Compareendiftcnt0 port 0x32 ; Timer 0 Count Registerocr0 port 0x3cif __cpucode>=0x012313tccr1a port 0x2f ; Timer 1 Steuerregister A:pwm10 equ 0 ; PWM Modewgm10 equ pwm10pwm11 equ 1wgm11 equ pwm11com1a0 equ 6 ; Compare Mode Acom1a1 equ 7if __cpucode>=0x014414com1b0 equ 4 ; Compare Mode Bcom1b1 equ 5endifif ismega(__cpucode)foc1b equ 2foc1a equ 3endiftccr1b port 0x2e ; Timer 1 Control Register B:cs10 equ 0 ; Prescale settingcs11 equ 1cs12 equ 2ctc1 equ 3 ; Reset after Equality ?wgm12 equ ctc1if ismega(__cpucode)wgm13 equ 4endifices1 equ 6 ; Capture Edge Selectionicnc1 equ 7 ; Capture Noise Filtertcnt1l port 0x2c ; Timer 1 Count Register (LSB)tcnt1h port 0x2d ; (MSB)if __cpucode>=0x014414ocr1al port 0x2a ; Timer 1 Compare Register A (LSB)ocr1ah port 0x2b ; (MSB)ocr1bl port 0x28 ; Timer 1 Compare Register B (LSB)ocr1bh port 0x29 ; (MSB)elseifocr1l port 0x2a ; Timer 1 Compare Register (LSB)ocr1h port 0x2b ; (MSB)endifif ismega(__cpucode)icr1l port 0x26icr1h port 0x27elseificr1l port 0x24 ; Timer 1 Capture Value (LSB)icr1h port 0x25 ; (MSB)endifendifif ismega(__cpucode)tccr2 port 0x26 ; Timer 2 Control Registercs20 equ 0 ; Prescalercs21 equ 1cs22 equ 2wgm21 equ 3com20 equ 4com21 equ 5wgm20 equ 6foc2 equ 7tcnt2 port 0x24 ; Timer Valueocr2 port 0x23 ; Output Compare Valueassr port 0x22 ; Asynchronous Status Registeras2 equ 3 ; Asynchronous Timer 2tcn2ub equ 2 ; Timer/Counter 2 Update Busyocr2ub equ 1 ; Output Compare Register 2 Update Busytcr2ub equ 0 ; Timer/Counter Control Register 2 Update Busyendif;----------------------------------------------------------------------------; Watchdogwdtcr port 0x21 ; Watchdog-Control Register:wdp0 equ 0 ; Prescalerwdp1 equ 1wdp2 equ 2wde equ 3 ; Enableif __cpucode=0x010008wdce equ 4 ; Watchdog Change Enableelseif __cpucode>=0x012313wdttoe equ 4 ; Needed for Disableendif;----------------------------------------------------------------------------; serielle Portsif __cpucode>=0x012312udr port 0x0c ; Data Register UARTusr port 0x0b ; Status Register UART:ucsra port usrif ismega(__cpucode)mpcm equ 0 ; Multiprocessor Communication Modeu2x equ 1 ; Double Speedpe equ 2 ; Parity Errorendifor equ 3 ; Receiver Overflowdor equ orfe equ 4 ; Framing Errorudre equ 5 ; Data Register Emptytxc equ 6 ; Transmission Completerxc equ 7 ; Reception Completeucr port 0x0a ; UART Control Register:ucsrb port ucrtxb8 equ 0 ; Transmit Bit 8rxb8 equ 1 ; Receive Bit 8chr9 equ 2 ; Enable 9 Bit Data Valuesucsz2 equ chr9txen equ 3 ; Transmitter Enablerxen equ 4 ; Receiver Enableudrie equ 5 ; Enable Free Data Register Interrupttxcie equ 6 ; Enable Transmit Complete Interruptrxcie equ 7 ; Enable Receive Complete Interruptif ismega(__cpucode)ucsrc port 0x20 ; Control Register Cursel equ 7 ; Register Selectumsel equ 6 ; Sync/Async Modeupm1 equ 5 ; Parity Modeupm0 equ 4usbs equ 3 ; Stop Bit Selectucsz1 equ 2 ; Character Sizeucsz0 equ 1ucpol equ 0 ; Clock Polarityendifubrr port 0x09 ; Baud Rate Generatorif ismega(__cpucode)ubrrl port ubrrubrrh port ucsrcendifendifif __cpucode>=0x014414spcr port 0x0d ; SPI Control Register:spr0 equ 0 ; Clock Selectionspr1 equ 1cpha equ 2 ; Clock Phasecpol equ 3 ; Clock Polaritymstr equ 4 ; Master/Slave Selectdord equ 5 ; Bit Orderspe equ 6 ; SPI Enablespie equ 7 ; SPI Interrupt Enablespsr port 0x0e ; SPI Status Register:if ismega(__cpucode)spi2x equ 0 ; Double Speed Modeendifwcol equ 6 ; Write Collision ?spif equ 7 ; SPI Interrupt Flagspdr port 0x0f ; SPI Data Registerendifif ismega(__cpucode)twbr port 0x00 ; Bit Rate Registertwcr port 0x36 ; Control Registertwint equ 7 ; Interrupt Flagtwea equ 6 ; Enable Acknowledge Bittwsta equ 5 ; Start Conditiontwsto equ 4 ; Stop Conditiontwwc equ 3 ; Write Collision Flagtwen equ 2 ; Enable Bittwie equ 0 ; Interupt Enabletwsr port 0x01 ; Status Registertws7 equ 7 ; Statustws6 equ 6tws5 equ 5tws4 equ 4tws3 equ 3twps1 equ 1 ; Prescalertwps0 equ 0twdr port 0x03 ; Data Registertwar port 0x02 ; (Slave) Address Registertwgce equ 0 ; General Call recognition Bitendif;----------------------------------------------------------------------------; Analog Comparatoracsr port 0x08 ; Comparator Control/Status Register:acis0 equ 0 ; Interrupt Modeacis1 equ 1if __cpucode>=0x012313acic equ 2 ; Use Comparator as Capture Signal for Timer 1endifacie equ 3 ; Interrupt Enableaci equ 4 ; Interrupt Flagaco equ 5 ; Comparator Outputif ismega(__cpucode)acbg equ 6 ; Bandgap Selectendifacd equ 7 ; Power Off;----------------------------------------------------------------------------; A/D Converterif ismega(__cpucode)admux port 0x07 ; Multiplexer Selectionrefs1 equ 7 ; reference Selection Bitsrefs0 equ 6adlar equ 5 ; Left Adjust Rightmux3 equ 3 ; Multiplexermux2 equ 2mux1 equ 1mux0 equ 0if __cpucode >=0x020010adcsra port 0x06 ; Control/Status Registeradate equ 5 ; Auto Trigger Enableelseifadcsr port 0x06 ; Control/Status Registeradfr equ 5 ; free Running Selectendifaden equ 7 ; Enable ADCadsc equ 6 ; Start Conversionadif equ 4 ; Interrupt Flagadie equ 3 ; Interrupt Enableadps2 equ 2 ; Prescaler Selectadps1 equ 1adps0 equ 0adch port 0x05 ; Data Registeradcl port 0x04endif;----------------------------------------------------------------------------; JTAGif __cpucode >=0x020010ocdr port osccal ; Debug Registerendif;----------------------------------------------------------------------------; EEPROMif eeend>=256eearl port 0x1e ; Address Registereearh port 0x1felseifeear port 0x1eendifeedr port 0x1d ; Data Registereecr port 0x1c ; Control Register:eere equ 0 ; Read Enableeewe equ 1 ; Write Enableif __cpucode>=0x012313eemwe equ 2endifif __cpucode=0x020008eerie equ 3 ; Enable Ready Interruptendif;----------------------------------------------------------------------------; Vectors; Unfortunately, interrupt numbers change for biggger processors; Why only, Atmel, why ?vec_reset label 0 ; Reset Entryswitch __cpucodecase 0x011200vec_int0 label 1 ; Entry External Interrupt 0vec_tm0ovf label 2 ; Entry Overflow Timer 0vec_anacomp label 3 ; Entry Analog Comparatorcase 0x012313vec_int0 label 1 ; Entry External Interrupt 0vec_int1 label 2 ; Entry External Interrupt 2vec_tm1capt label 3 ; Entry Capture Timer 1vec_tm1comp label 4 ; Entry Compare Timer 1vec_tm1ovf label 5 ; Entry Overflow Timer 1vec_tm0ovf label 6 ; Entry Overflow Timer 0vec_uartrx label 7 ; Entry UART Empfang komplettvec_uartudre label 8 ; Entry UART Data Register leervec_uarttx label 9 ; Entry UART Sendung komplettvec_anacomp label 10 ; Entry Analog-Komparatorcase 0x014414,0x018515vec_int0 label 1 ; Entry External Interrupt 0vec_int1 label 2 ; Entry External Interrupt 2vec_tm1capt label 3 ; Entry Capture Timer 1vec_tm1compa label 4 ; Entry Compare A Timer 1vec_tm1compb label 5 ; Entry Compare A Timer 1vec_tm1ovf label 6 ; Entry Overflow Timer 1vec_tm0ovf label 7 ; Entry Overflow Timer 0vec_spi label 8 ; Entry SPI Interruptvec_uartrx label 9 ; Entry UART Reception Completevec_uartudre label 10 ; Entry UART Data Register Emptyvec_uarttx label 11 ; Entry UART Sendung Completevec_anacomp label 12 ; Entry Analog Comparatorcase 0x020008vec_int0 label 1 ; Entry External Interrupt 0vec_int1 label 2 ; External Interrupt 1vec_tm2comp label 3 ; Timer 2 Compare Matchvec_tm2ovf label 4 ; Timer 2 Overflowvec_tm1capt label 5 ; Timer 1 Capturevec_tm1compa label 6 ; Timer 1 Compare Match Avec_tm1compb label 7 ; Timer 1 Compare Match Bvec_tm1ovf label 8 ; Timer 1 Overflowvec_tm0ovf label 9 ; Timer 0 Overflowvec_spi label 10 ; SPI Transfer Completevec_uartrx label 11 ; UART Rx Completevec_uartudre label 12 ; UART Data Register Emptyvec_uarttx label 13 ; UART Tx Completevec_adc label 14 ; ADC Conversion Completevec_eerdy label 15 ; EEPROM Readyvec_anacomp label 16 ; analog Comparatorvec_twi label 17 ; Two-Wire Interfacevec_spm_rdy label 18 ; Store Program Memory Readycase 0x020010vec_int0 label 2 ; External Interrupt 0vec_int1 label 4 ; External Interrupt 1vec_tm2comp label 6 ; Timer 2 Compare Matchvec_tm2ovf label 8 ; Timer 2 Overflowvec_tm1capt label 10 ; Timer 1 Capturevec_tm1compa label 12 ; Timer 1 Compare Match Avec_tm1compb label 14 ; Timer 1 Compare Match Bvec_tm1ovf label 16 ; Timer 1 Overflowvec_tm0ovf label 18 ; Timer 0 Overflowvec_spi label 20 ; SPI Transfer Completevec_uartrx label 22 ; UART Rx Completevec_uartudre label 24 ; UART Data Register Emptyvec_uarttx label 26 ; UART Tx Completevec_adc label 28 ; ADC Conversion Completevec_eerdy label 30 ; EEPROM Readyvec_anacomp label 32 ; analog Comparatorvec_twi label 34 ; Two-Wire Interfacevec_int2 label 36 ; External Interrupt 2vec_tm0comp label 38 ; Timer 0 Compare Matchvec_spm_rdy label 40 ; Store Program Memory Readyendcase;----------------------------------------------------------------------------restore ; re-allow listingendif ; __regavrinc