Path: Home => AVR-overview => Assembler introduction => Ports => Details

Introduction to AVR assembler programming for beginners

The table of the relevant ports in the ATMEL AVR types AT90S2313, 2323 and 8515. Bytewise accessable ports or register pairs are not displayed in detail. No warranty for correctness, see the data sheets!

Status-Register, Accumulator flags

PortFunctionPort-AddressRAM-Address
SREGStatus Register Accumulator0x3F0x5F
7654 3210
ITHSVNZC
BitNameMeaningOpportunitiesConand
7IGlobal Interrupt Flag 0: Interrupts disabledCLI
1: Interrupts enabledSEI
6TBit storage 0: Stored bit is 0CLT
1: Stored bit is 1SET
5HHalfcarry-Flag 0: No halfcarry occuredCLH
1: Halfcarry occuredSEH
4SSign-Flag 0: Sign positiveCLS
1: Sign negativeSES
3VTwo's complement-Flag 0: No carry occuredCLV
1: Carry occuredSEV
2NNegative-Flag 0: Result was not negative/smallerCLN
1: Result was negative/smallerSEN
1ZZero-Flag 0: Result was not zero/unequalCLZ
1: Result was zero/equalSEZ
0CCarry-Flag 0: No carry occuredCLC
1: Carry occuredSEC


To the top of that page

Stackpointer

PortFunctionPort-AddressRAM-Address
SPL/SPHStackpointer003D/0x3E0x5D/0x5E
NameMeaningVerfügbarkeit
SPLLow-Byte of StackpointerFrom AT90S2313 upwards, not in 1200
SPHHigh-Byte of StackpointerFrom AT90S8515 upwards, only in devices with >256 bytes internal SRAM


To the top of that page

SRAM and External Interrupt control

PortFunctionPort-AddressRAM-Address
MCUCRMCU General Control Register0x350x55
7654 3210
SRESRWSESMISC11ISC10ISC01ISC00
BitNameMeaningOpportunities
7SREExt.SRAM Enable 0=No external SRAM connected
1=External SRAM connected
6SRWExt.SRAM Wait States 0=No extra wait state on external SRAM
1=Additional wait state on external SRAM
5SESleep Enable 0=Ignore SLEEP commands
1=SLEEP on command
4SMSleep Mode 0=Idle Mode (Half sleep)
1=Power Down Mode (Full sleep)
3ISC11Interrupt control Pin INT1
(connected to GIMSK)
00: Low-level initiates Interrupt
01: Undefined
2ISC1010: Falling edge triggers interrupt
11: Rising edge triggers interrupt
1ISC01Interrupt control Pin INT0
(connected to GIMSK)
00: Low-level initiates interrupt
01: Undefined
0ISC0010: Falling edge triggers interrupt
11: Rising edge triggers interrupt


To the top of that page

External Interrupt Control

PortFunctionPort-AddressRAM-Address
GIMSKGeneral Interrupt Maskregister0x3B0x5B
7654 3210
INT1INT0------
BitNameMeaningOpportunities
7INT1Interrupt by external pin INT1
(connected to mode in MCUCR)
0: External INT1 disabled
1: External INT1 enabled
6INT0Interrupt by external Pin INT0
(connected to mode in MCUCR)
0: External INT0 disabled
1: External INT0 enabled
0...5(Not used)


PortFunctionPort-AddressRAM-Address
GIFRGeneral Interrupt Flag Register0x3A0x5A
7654 3210
INTF1INTF0------
BitNameMeaningOpportunities
7INTF1Interrupt by external pin INT1 occured Automatic clear by execution of the Int-Routine or
Clear by command
6INTF0Interrupt by external pin INT0 occured
0...5(Not used)


To the top of that page

Timer Interrupt Control

PortFunctionPort-AddressRAM-Address
TIMSKTimer Interrupt Maskregister0x390x59
7654 3210
TOIE1OCIE1AOCIE1B-TICIE1-TOIE0-
BitNameMeaningOpportunities
7TOIE1Timer/Counter 1 Overflow-Interrupt0: No Int at overflow
1: Int at overflow
6OCIE1ATimer/Counter 1 Compare A Interrupt0: No Int at equal A
1: Int at equal A
5OCIE1BTimer/Counter 1 Compare B Interrupt0: No Int at B
1: Int at equal B
4(Not used)
3TICIE1Timer/Counter 1 Capture Interrupt0: No Int at Capture
1: Int at Capture
2(Not used)
1TOIE0Timer/Counter 0 Overflow-Interrupt0: No Int at overflow
1: Int at overflow
0(Not used)


PortFunctionPort-AddressRAM-Address
TIFRTimer Interrupt Flag Register0x380x58
7654 3210
TOV1OCF1AOCF1B-ICF1-TOV0-
BitNameMeaningOpportunities
7TOV1Timer/Counter 1 Overflow reached Interrupt-Mode:
Automatic Clear
by execution of the
Int-Routine

OR

Polling-Mode:
Clear by
command
6OCF1ATimer/Counter 1 Compare A reached
5OCF1BTimer/Counter 1 Compare B reached
4(Not used)
3ICF1Timer/Counter 1 Capture-Event occured
2(not used)
1TOV0Timer/Counter 0 Overflow occured
0(not used)


To the top of that page

Timer/Counter 0

PortFunctionPort-AddressRAM-Address
TCCR0Timer/Counter 0 Control Register0x330x53
7654 3210
-----CS02CS01CS00
BitNameMeaningOpportunities
2..0CS02..CS00Timer Clock 000: Stop Timer
001: Clock = Chip clock
010: Clock = Chip clock / 8
011: Clock = Chip clock / 64
100: Clock = Chip clock / 256
101: Clock = Chip clock / 1024
110: Clock = falling edge of external Pin T0
111: Clock = rising edge of external Pin T0
3..7(not used)


PortFunctionPort-AddressRAM-Address
TCNT0Timer/Counter 0 count register0x320x52


To the top of that page

Timer/Counter 1

PortFunctionPort-AddressRAM-Address
TCCR1ATimer/Counter 1 Control Register A0x2F0x4F
7654 3210
COM1A1COM1A0COM1B1COM1B0--PWM11PWM10
BitNameMeaningOpportunities
7COM1A1Compare Output A 00: OC1A/B not connected
01: OC1A/B changes polarity
10: OC1A/B to zero
11: OC1A/B to one
6COM1A0
5COM1B1Compare Output B
4COM1B0
3(not used)
2
1..0PWM11
PWM10
Pulse width modulator 00: PWM off
01: 8-Bit PWM
10: 9-Bit PWM
11: 10-Bit PWM


PortFunctionPort-AddressRAM-Address
TCCR1BTimer/Counter 1 Control Register B0x2E0x4E
7654 3210
ICNC1ICES1--CTC1CS12CS11CS10
BitNameMeaningOpportunities
7ICNC1Noise Canceler
on ICP-Pin
0: disabled, first edge starts sampling
1: enabled, min four clock cycles
6ICES1Edge selection
on Capture
0: falling edge triggers Capture
1: rising edge triggers Capture
5..4(not used)
3CTC1Clear at
Compare Match A
1: Counter set to zero if equal
2..0CS12..CS10Clock select000: Counter stopped
001: Clock
010: Clock / 8
011: Clock / 64
100: Clock / 256
101: Clock / 1024
110: falling edge external Pin T1
111: rising edge external Pin T1


PortFunctionPort-AddressRAM-Address
TCNT1L/HTimer/Counter 1 count register0x2C/0x2D0x4C/0x4D


PortFunctionPort-AddressRAM-Address
OCR1AL/HTimer/Counter 1 Output Compare register A0x2A/0x2B0x4A/0x4B hex


PortFunctionPort-AddressRAM-Address
OCR1BL/HTimer/Counter 1 Output Compare register B0x28/0x290x48/0x49


PortFunctionPort-AddressRAM-Address
ICR1L/HTimer/Counter 1 Input Capture Register0x24/0x250x44/0x45


To the top of that page

Watchdog-Timer

PortFunctionPort-AddressRAM-Address
WDTCRWatchdog Timer Control Register0x210x41
7654 3210
---WDTOEWDEWDP2WDP1WDP0
BitNameMeaningWDT-cycle at 5.0 Volt
7..5(not used)
4WDTOEWatchdog Turnoff EnablePrevious set to
disabling of WDE required
3WDEWatchdog Enable1: Watchdog aktive
2..0WDP2..WDP0Watchdog Timer Prescaler000: 15 ms
001: 30 ms
010: 60 ms
011: 120 ms
100: 240 ms
101: 490 ms
110: 970 ms
111: 1,9 s


To the top of that page

EEPROM

PortFunctionPort-AddressRAM-Address
EEARL/HEEPROM Address Register0x1E/0x1F0x3E/0x3F
EEARH only in types with more than 256 Bytes EEPROM (from AT90S8515 upwards)

PortFunctionPort-AddressRAM-Address
EEDREEPROM Data Register0x1D0x3D


PortFunctionPort-AddressRAM-Address
EECREEPROM Control Register0x1C0x3C
7654 3210
-----EEMWEEEWEEERE
BitNameMeaningFunction
7..3(not used)
2EEMWEEEPROM Master Write EnablePrevious set enables write cycle
1EEWEEEPROM Write EnableSet to initiate write
0EEREEEPROM Read EnableSet initiates read


To the top of that page

Serial Peripheral Interface SPI

PortFunctionPort-AddressRAM-Address
SPCRSPI Control Register0x0D0x2D
7654 3210
SPIESPEDORDMSTRCPOLCPHASPR1SPR0
BitNameMeaningFunction
7SPIESPI Interrupt Enable 0: Interrupts disabled
1: Interrupts enabled
6SPESPI Enable 0: SPI disabled
1: SPI enabled
5DORDData Order 0: MSB first
1: LSB first
4MSTRMaster/Slave Select 0: Slave
1: Master
3CPOLClock Polarity 0: Positive Clock Phase
1: Negative Clock Phase
2CPHAClock Phase 0: Sampling at beginning of Clock Phase
1: Sampling at end of Clock Phase
1SPR1SCK clock frequency 00: Clock / 4
01: Clock / 16
0SPR010: Clock / 64
11: Clock / 128


PortFunctionPort-AddressRAM-Address
SPSRSPI Status Register0x0E0x2E
7654 3210
SPIFWCOL------
BitNameMeaningFunction
7SPIFSPI Interrupt FlagInterrupt request
6WCOLWrite Collision Flag Write collission occured
5..0(not used)


PortFunctionPort-AddressRAM-Address
SPDRSPI Data Register0x0F0x2F


To the top of that page

UART

PortFunctionPort-AddressRAM-Address
UDRUART I/O Data Register0x0C0x2C


PortFunctionPort-AddressRAM-Address
USRUART Status Register0x0B0x2B
7654 3210
RXCTXCUDREFEOR---
BitNameMeaningFunction
7RXCUART Receive Complete1: Char received
6TXCUART Transmit Complete1: Shift register empty
5UDREUART Data Register Empty1: Transmit register available
4FEFraming Error1: Illegal Stop-Bit
3OROverrun1: Lost char
2..0(not used)


PortFunctionPort-AddressRAM-Address
UCRUART Control Register0x0A0x2A
7654 3210
RXCIETXCIEUDRIERXENTXENCHR9RXB8TXB8
BitNameMeaningFunction
7RXCIERX Complete Interrupt Enable1: Interrupt on received char
6TXCIETX Complete Interrupt Enable1: Interrupt at transmit complete
5UDRIEData Register Empty Interrupt Enable1: Interrupt on transmit buffer empty
4RXENReceiver Enabled1: Receiver enabled
3TXENTransmitter Enable1: Transmitter enabled
2CHR99-bit Characters1: Char length 9 Bit
1RXB8Receive Data Bit 89th Data bit on receive
0TXB8Transmit Data Bit 89.Data bit on transmit


PortFunctionPort-AddressRAM-Address
UBRRUART Baud Rate Register0x090x29


To the top of that page

Analog Comparator

PortFunctionPort-AddressRAM-Address
ACSRAnalog Comparator Control and Status Register0x080x28
7654 3210
ACD-ACOACIACIEACICACIS1ACIS0
BitNameMeaningFunction
7ACDDisableDisable Comparators
6(not used)
5ACOComparator OutputRead: Output of the Comparators
4ACIInterrupt Flag1: Interrupt request
3ACIEInterrupt Enable1: Interrupts enabled
2ACICInput Capture Enable1: Connect to Timer 1 Capture
1ACIS1Input Capture Enable 00: Interrupt on edge change
01: not used)
0ACIS010: Interrupt on falling edge
11: Interrupt on rising edge


To the top of that page

I/O Ports

PortRegisterFunctionPort-AddressRAM-Address
APORTAData Register0x1B0x3B
DDRAData Direction Register0x1A0x3A
PINAInput Pins Address0x190x39
BPORTBData Register0x180x38
DDRBData Direction Register0x170x37
PINBInput Pins Address0x160x36
CPORTCData Register0x150x35
DDRCData Direction Register0x140x34
PINCInput Pins Address0x130x33
DPORTDData Register0x120x32
DDRDData Direction Register0x110x31
PINDInput Pins Address0x100x30


To the top of that page

©2002 by http://www.avr-asm-tutorial.net