Professional Documents
Culture Documents
1. C
http://en.wikipedia.org/wiki/C(programming_language)
2. C http://openhome.cc/Gossip/CGossip/
3. ATmega128(L) Complete.pdf
1. PC
2. AVRM128 www.viewmove.com
3. WinAVR Programmer's Notepad
4. Windows
5.
6.
1
7. 40PIN
1
8.
1
9. TEN BAR LED 1
10. DIP Switch 2
11.
CPU
CPU
BIT
bit
AVR ATMega128
MEMORY MAP IO
C CPU
C
AVR ATMega128
GCC
AVR ATMega128
(Functional Based)
()
(Register Based)
Register
Based IC IT
Functional based
Register Based
Parallel Port
CPU
AVR
PORTx
DDRx PINx PINx
PORTxDDRx
()
DDRx
(1)(0) PORTx
()
IC (Pull Low/Pull
Down)(Pull Low/Pull Up)
AVR Pull Up AVR
() AVR Pull Up Pull Down
AVR
register based
void MyOutPortA_set(void){
DDRA=0xFF;// DDRA 1 PORTA ,
DDRA
}
void MyInPortA_set(void){
DDRA=0X00;// DDRA 0 PORTA
}
void MyOutPortA_put(Char value){
PORTA=value;// PORTA
PORTA
}
char MyInPortA_get(void){
return(PINA); // PINA PORTA
AVR PINA
}
2. AVR Atmega128
LED
3. AVR ABC
8 1
Mask
Mask
4. AVR 8
value mask
shift DIO_fpt()
1 0xFF
0
Char DIO_fpt(char LSByte, char Mask, char shift, char
Data)
IO Port
LSByte0~3 PORTA/PORTB/PORTC/PORTE
Maskbit 1 bit
Shift Data
Data
LSByte0~3 PORTA/PORTB/PORTC/PORTE
Maskbit 1 bit
Shift Data_p
Data_p
RETURN 0
0
1LSByte ( byte )
2Shift ( 7 )
M128_DIO
M128_DIO 4 PortA, PortB, PortC, PortE
LSByte Port
b7
b6
b5
b4
b3
b2
b1
b0
PortA
PA7
PA6
PA5
PA4
PA3
PA2
PA1
PA0
PortB
PB7
PB6
PB5
PB4
PB3
PB2
PB1
PB0
PortC
PC7
PC6
PC5
PC4
PC3
PC2
PC1
PC0
PortE
PE7
PE6
PE5
PE4
PE3
PE2
PE1
PE0
AVR Atmega128
#include ASA_Lib.h
/
AVR ATmega128
(TEN BAR LED)
LED AVR ATmega128
1.
RS232 PC
AVR M128 PC
Mega128 40PIN
AVR M128 PORTB
LED PORTA
PORTB,PORTA
Mega128
Hi
Low
Mega128 Hi/Low
/
LED PORTA
PC
UART
PORTA
AVR
PORTB
LED
1 Hi LED
1
PORTAn
PORTBn
MyOutPortX_set(), MyInPortX_set(),
MyOutPortX_put(),MyInPortX_get(void)
main()
MyInPortA_set() A
MyOutPortB_set() B
while(1){
MyInPortA_get()
printf()
printf()
scanf()
MyOutPortB_put()
}
2.
PortA HI/LO
PortB RS232 PC
PortA
PortB
RS232
PortB
1
3. LED
2 P1
BIT LED
PortA
PortA
PortB
PortB
RS232
PortB
2
4.
main()
while(1){
DIO_fgt() PORTA7:6 6
2
printf() PC
DIO_fgt() PORTA5:4 4
2
printf() PC
printf()
scanf() value
printf()
scanf() shift
DIO_fpt()
}
5.
HILO
UP_EVENT DOWN_EVENT
While(1){
DIO_fgt() PORTA HILO
HILO HILO HI LO LO HI
DOWN_EVENTUP_EVENT
printf() HILO
UP_EVENT DOWN_EVENT
}
6.
2 PORTA 4
PORTB 4
PC
PORTA
4
AVR
UART PORTA
AVR 4
2
4 0 1 PortA 4
PortB 4 RS232
1
<16
PortA 4
PortA 4
RS232
1.
2. ///()
()
()
3.
4.
AVR M128
AVR M128
AVR M128
5.
1 LED HI
LO LED ?
2 LED ?
WIN AVR
AVR M128
BIT LED
AVR M128
**
ASA_M128
VCC(5V)GND