[전자공학실험] AVR Training Board-I (영어,영문)
본 자료는 4페이지 의 미리보기를 제공합니다. 이미지를 클릭하여 주세요.
닫기
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
해당 자료는 4페이지 까지만 미리보기를 제공합니다.
4페이지 이후부터 다운로드 후 확인할 수 있습니다.

소개글

[전자공학실험] AVR Training Board-I (영어,영문)에 대한 보고서 자료입니다.

목차

AVR (Advanced Virtual RISC)

MegaAVR

ATmega128

Pin function in ATmege128

Experimental Results

HW1

HW2

HW3

본문내용

1 second, we can use the function _delay_ms() in util.delay header file. After maintaining 1 second using _delay_ms, as all the LED should be turned on, the value should be 0011 1100. It is converted to 3 C in hexadecimal digit. Declare PORTD = 0x3C and maintain the state for 1 second using _delay_ms() function. Finally, to make the loop infinite and state return to the initial state we used while(1).
3.HW2
A.Source Code
#include
#include
#define F_CPU 11059200UL
int main()
{
unsigned int i;
DDRD = 0xff;
PORTD = 0x01;
while(1){
for(i=0;i<8;i++)
{
_delay_ms(200);
PORTD = PORTD << 1;
}
PORTD = 0x10;
for(i=0;i<8;i++)
{
_delay_ms(400);
PORTD = PORTD >> 1;
}
PORTD = 0x01;
}
return 0;
}
B.Data
C.Discussion
It is an application of ex1, we can see that the LED turns on 1 bit up orderly, and turns on 1 bit down orderly as a result. In other words, moves 1bit to the left, with PORTD = 0x10; among the 4 LED, the very top LED returns to an initial value. Afterwards, with “for” statement, move 1 bit to the right so that to turn on the LED downwards in order. With PORTD = 0x01; turn on the LED which was turned on at the beginning.
4.HW3
A.Source Code
#include
int main(void){
DDRC = 0x00;// port C의 bit 7:0 을 Read으로 선언
DDRD = 0x3C;// port D의 bit 5:2 를 Write으로 선언
while(1){
if(PINC != 0x0F)// pin C의 bit 3:0가 high가 아니라면 작동
PORTD = (~(PINC<<2)) & 0x3C;
else
PORTD = 0x00;
}
return 0;
}
B.Data
When PINC = 0x01, PORTD = 0x04
When PINC = 0x04, PORTD = 0x10
When PINC = 0x05, PORTD = 0x14
When PINC = 0x07, PORTD = 0x1C
C.Discussion
When DDRn is ‘1’, it becomes read mode. when DDRn is ‘0’, it becomes Write mode.
DDRC = 0x00
7bit
6bit
5bit
4bit
3bit
2bit
1bit
0bit
0
0
0
0
0
0
0
0
R
R
R
R
R
R
R
R
Read all the bit of DDRC
DDRD = 0x3C
7bit
6bit
5bit
4bit
3bit
2bit
1bit
0bit
0
0
1
1
1
1
0
0
R
R
W
W
W
W
R
R
DDRD bit 5:2 Write
if(PINC != 0x0F)
PORTD = (~(PINC<<2)) & 0x3C;
Port C is connected to the switches. The ones we used were bit 3:0 of portC. When a pin is ‘1’, It becomes off state. When a pin is 0, it becomes on state. As “if” statement activates when all the bit 3:0 of pinc is not ‘1’, it operates when no switches are pressed. It gets the switches’ on/off information with PINC and shift 2 bit to the left. Then reverse ‘0’ with ‘1’, ‘1’ with ‘0’ which is the pin state and compare portC which is the port of LED with 0x3C which is in writing mode. When both are 1, bit of portD has a value ‘1’.
For example, press bit2 and bit0 of the switch.
PINC=0x05
7bit
6bit
5bit
4bit
3bit
2bit
1bit
0bit
0
0
0
0
0
1
0
1
on
on

(PINC=0x05)<<2
7bit
6bit
5bit
4bit
3bit
2bit
1bit
0bit
0
0
0
1
0
1
0
0
on
on

~((PINC=0x05)<<2)
7bit
6bit
5bit
4bit
3bit
2bit
1bit
0bit
1
1
1
0
1
0
1
1
&
PORTD=0x3C
7bit
6bit
5bit
4bit
3bit
2bit
1bit
0bit
0
0
1
1
1
1
0
0
↓↓
As 5bit and 3 bit are both ‘1’, 5bit and 3bit of PORTD is ‘1’.
PORTD
7bit
6bit
5bit
4bit
3bit
2bit
1bit
0bit
0
0
1
0
1
0
0
0
When bit2 and bit0 of the switch is pressed, 5bit and 3bit of LED port turn on.
  • 가격2,000
  • 페이지수12페이지
  • 등록일2015.03.13
  • 저작시기2015.3
  • 파일형식한글(hwp)
  • 자료번호#959565
본 자료는 최근 2주간 다운받은 회원이 없습니다.
다운로드 장바구니