BASIC4MCU | 질문게시판 | ATMEGA128 UART,FND 연동 질문
페이지 정보
작성자 JMOD 작성일2022-06-19 02:25 조회5,550회 댓글0건본문
uart로 숫자를 입력 받아 fnd에서 나타나게 하는 소스코드를 작성중인데 자꾸 fnd에 정상적인 숫자가 나타나지 않고 출력이 이상하게 됩니다
#include <avr/io.h>
#define F_CPU 16000000UL
#include <util/delay.h>
#include <avr/interrupt.h>
void init_uart0()
{
UCSR0B = 0x18;
UCSR0C = 0x06;
UBRR0H = 0;
UBRR0L = 103;
}
void putchar0(char c)
{
while(!(UCSR0A & (1<<UDRE0))) ;
UDR0 = c;
}
char getchar0()
{
while (!(UCSR0A & (1<<RXC0)))
;
return(UDR0);
}
int main()
{
unsigned char FND[]={0x3F,0X06,0X5B,0X4F,0X66,0X6D,0X7C,0X07,0X7F,0X67};
int value;
init_uart0();
DDRC=0xff;
DDRG=0x0f;
while(1)
{
value = getchar0();
putchar0(value);
PORTC=FND[value];
PORTG=0x01;
}
while(value)
{
_delay_ms(100);
PORTC=FND[value];
PORTG=0x01;
}
}
댓글 0
조회수 5,550등록된 댓글이 없습니다.