본문 바로가기

프로테우스/USART

통신 -LED 제어


#include 
#include 
#include 
#include 

char rx;

interrupt[USART0_RXC]void usart0_rxc(void){
    rx=UDR0; 
    
    if(rx=='1')PORTC=1; 
    if(rx=='2')PORTC=2; 
    if(rx=='3')PORTC=4; 
    if(rx=='4')PORTC=8; 

    
}

void TX0_CHAR(char Sdata){ while(!(UCSR0A&0x20)); UDR0=Sdata; } // 송신함수

void main(void)
{
    DDRC=0xff;  //LED
    UCSR0B=0x98; UCSR0C=6; UBRR0H=0; UBRR0L=103; 
    #asm("sei") 
}