반응형
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51 |
#include <avr/io.h>
#define F_CPU 16000000
#include <util/delay.h>
#include "lcd.h"
#include <stdio.h>
#include <stdlib.h>
#define LED_SEL1 (*(volatile unsigned char *)0xA000)
#define LED_SEL2 (*(volatile unsigned char *)0xB000)
#define FND (*(volatile unsigned char *)0x8000)
void io_init(void)
{
MCUCR|=(1<<SRE) | (1<<SRW10);
XMCRA=(1<<SRL2) | (0<<SRL1) | (0<<SRL0) | (1<<SRW01) | (1<<SRW00) | (1<<SRW11);
XMCRB |= 0x00;
}
void fndController (char loc , char number){
FND = (number <<3)|loc;
}
void fndDisplay (unsigned long long number){
fndController(5,number%10);_delay_ms(1);
fndController(4,(number%100)/10);_delay_ms(1);
fndController(3,(number%1000)/100);_delay_ms(1);
fndController(2,(number%10000)/1000);_delay_ms(1);
fndController(1,(number%100000)/10000);_delay_ms(1);
fndController(0,number/100000);_delay_ms(1);
}
int main(void)
{
io_init();
lcd_init();
lcd_clear();
DDRE = 0x00;
PORTE = 0xff;
int count=0;
char str[16];
while (1)
{
itoa(PINE,str,2);
sprintf(str,"C:%d",count);
}
}
|
cs |
// 스위치를 입력할 경우 LCD 2진수가 출력된다.
//디버깅에 용이하다
반응형
'Study > 8-bit MCUs' 카테고리의 다른 글
[NPAVR Board] AVR - Atmega128 (keyMatrix) (0) | 2018.09.04 |
---|---|
[NPAVR Board] AVR - Atemga128 (ADC, CDS) (0) | 2018.09.04 |
[NPAVR Board] AVR - Atmega128 (Character LCD) (0) | 2018.09.04 |
[NPAVR Board] AVR -Atmega128 (FND, Switch) (0) | 2018.09.03 |
[NPAVR Board] AVR -Atmega128 (FND) (0) | 2018.09.03 |