atmega16.txt

(32 KB) Pobierz
Features...........................................................  1
Pin Configurations.................................................  2
Disclaimer.........................................................  2
Overview...........................................................  3
	Block Diagram..................................................  3
	Pin Descriptions...............................................  4
		VCC........................................................  4
		GND........................................................  4
		Port A (PA7..PA0)..........................................  4
		Port B (PB7..PB0)..........................................  5
		Port C (PC7..PC0)..........................................  5
		Port D (PD7..PD0)..........................................  5
		RESET......................................................  5
		XTAL1......................................................  5
		XTAL2......................................................  5
		AVCC.......................................................  5
		AREF.......................................................  5
Resources..........................................................  6
Data Retention.....................................................  6
About Code Examples................................................  7
AVR CPU Core.......................................................  8
	Introduction...................................................  8
	Architectural Overview.........................................  8
	ALU – Arithmetic Logic Unit....................................  9
	Status Register................................................  9
	General Purpose Register File.................................. 11
		The X-register, Y- register and Z-register................. 12
	Stack Pointer.................................................. 12
	Instruction Execution Timing................................... 13
	Reset and Interrupt Handling................................... 13
		Interrupt Response Time.................................... 15
AVR ATmega16 Memories.............................................. 16
	In-System Reprogrammable Flash Program Memory.................. 16
	SRAM Data Memory............................................... 17
		Data Memory Access Times................................... 18
	EEPROM Data Memory............................................. 18
		EEPROM Read/Write Access................................... 18
		The EEPROM Address Register – EEARH and EEARL.............. 19
		The EEPROM Data Register – EEDR............................ 19
		The EEPROM Control Register – EECR......................... 19
		EEPROM Write During Power-down Sleep Mode.................. 22
		Preventing EEPROM Corruption............................... 22
	I/O Memory..................................................... 23
System Clock and Clock Options..................................... 24
	Clock Systems and their Distribution........................... 24
		CPU Clock – clkCPU......................................... 24
		I/O Clock – clkI/O......................................... 24
		Flash Clock – clkFLASH..................................... 24
		Asynchronous Timer Clock – clkASY.......................... 24
		ADC Clock – clkADC......................................... 25
	Clock Sources.................................................. 25
	Default Clock Source........................................... 25
	Crystal Oscillator............................................. 25
	Low-frequency Crystal Oscillator............................... 28
	External RC Oscillator......................................... 28
	Calibrated Internal RC Oscillator.............................. 29
		Oscillator Calibration Register – OSCCAL................... 30
	External Clock................................................. 31
	Timer/Counter Oscillator....................................... 31
Power Management and Sleep Modes................................... 32
	MCU Control Register – MCUCR................................... 32
	Idle Mode...................................................... 33
	ADC Noise Reduction Mode....................................... 33
	Power-down Mode................................................ 33
	Power-save Mode................................................ 33
	Standby Mode................................................... 34
	Extended Standby Mode.......................................... 34
	Minimizing Power Consumption................................... 35
		Analog to Digital Converter................................ 35
		Analog Comparator.......................................... 35
		Brown-out Detector......................................... 35
		Internal Voltage Reference................................. 35
		Watchdog Timer............................................. 35
		Port Pins.................................................. 35
		JTAG Interface and On-chip Debug System.................... 36
System Control and Reset........................................... 37
	Resetting the AVR.............................................. 37
	Reset Sources.................................................. 37
	Power-on Reset................................................. 39
	External Reset................................................. 40
	Brown-out Detection............................................ 40
	Watchdog Reset................................................. 41
	MCU Control and Status Register – MCUCSR....................... 41
	Internal Voltage Reference..................................... 42
		Voltage Reference Enable Signals and Start-up Time......... 42
	Watchdog Timer................................................. 42
		Watchdog Timer Control Register – WDTCR.................... 43
Interrupts......................................................... 45
	Interrupt Vectors in ATmega16.................................. 45
		Moving Interrupts Between Application and Boot Space....... 48
		General Interrupt Control Register – GICR.................. 48
I/O Ports.......................................................... 50
	Introduction................................................... 50
	Ports as General Digital I/O................................... 50
		Configuring the Pin........................................ 51
		Reading the Pin Value...................................... 52
		Digital Input Enable and Sleep Modes....................... 54
		Unconnected pins........................................... 55
	Alternate Port Functions....................................... 55
		Special Function I/O Register – SFIOR...................... 57
		Alternate Functions of Port A.............................. 57
		Alternate Functions of Port B.............................. 58
		Alternate Functions of Port C.............................. 61
		Alternate Functions of Port D.............................. 63
	Register Description for I/O Ports............................. 66
		Port A Data Register – PORTA............................... 66
		Port A Data Direction Register – DDRA...................... 66
		Port A Input Pins Address – PINA........................... 66
		Port B Data Register – PORTB............................... 66
		Port B Data Direction Register – DDRB...................... 66
		Port B Input Pins Address – PINB........................... 66
		Port C Data Register – PORTC............................... 67
		Port C Data Direction Register – DDRC...................... 67
		Port C Input Pins Address – PINC........................... 67
		Port D Data Register – PORTD............................... 67
		Port D Data Direction Register – DDRD...................... 67
		Port D Input Pins Address – PIND........................... 67
External Interrupts................................................ 68
	MCU Control Register – MCUCR................................... 68
	MCU Control and Status Register – MCUCSR....................... 69
	General Interrupt Control Register – GICR...................... 69
	General Interrupt Flag Register – GIFR......................... 70
8-bit Timer/Counter0 with PWM...................................... 71
	Overview....................................................... 71
		Registers.................................................. 71
		Definitions................................................ 72
	Timer/Counter Clock Sources.................................... 72
	Counter Unit................................................... 72
	Output Compare Unit............................................ 73
		Force Output Compare....................................... 74
		Compare Match Blocking by TCNT0 Write...................... 74
		Using the Output Compare Unit.............................. 74
	Compare Match Output Unit...................................... 74
		Compare Output Mode and Waveform Generation................ 75
	Modes of Operation............................................. 76
		Normal Mode................................................ 76
		Clear Timer on Compare Match (CTC) Mode.................... 76
		Fast PWM Mode.............................................. 77
		Phase Correct PWM Mode..................................... 79
	Timer/Counter Timing Diagrams.................................. 81
	8-bit Timer/Counter Register Description....................... 83
		Timer/Counter Control Register – TCCR0..................... 83
		Timer/Counter Register – TCNT0............................. 85
		Output Compare Register – OCR0............................. 85
		Timer/Counter Interrupt Mask Register – TIMSK.............. 85
		Timer/C...
Zgłoś jeśli naruszono regulamin