BASIC4MCU | 질문게시판 | 답변 : 아트메가128 직렬통신 문자열출력
페이지 정보
작성자 master 작성일2019-11-21 19:19 조회3,360회 댓글0건
https://www.basic4mcu.com/bbs/board.php?bo_table=gac&wr_id=10803
본문
// MCU BASIC: https://www.basic4mcu.com// DateTime : 2019-11-21 오후 7:19:15// by Ok-Hyun Park//#include <iom128v.h>#include "lcd.h"//unsigned char data=0;unsigned char txStrData[]="20175153";unsigned char rxStrData[20]={0,};unsigned char rxbuffer=0;unsigned char countrxbuffer=0;//#pragma interrupt handler usart0_receive: iv_USART0_RXCvoid usart0_receive(void){rxbuffer=UDR0;rxStrData[countrxbuffer]=rxbuffer;if(++countrxbuffer>=8){ countrxbuffer=0;LCD_pos(1,0); LCD_STR(rxStrData);}}//void putch_USART0(unsigned char data){while(!(UCSR0A&(1<<UDRE0)));UDR0=data;}//void putSTR_USART0(char*s){while(*s)putch_USART0(*s++);}//void Init_USART0(void){UBRR0L=0x103;UCSR0B=(1<<RXEN0)|(1<<TXEN0)|(1<<RXCIE0);UCSR0C=(1<<UCSZ01)|(1<<UCSZ00)|(1<<UPM01);}//void main(void){PortInit();LCD_Init();LCD_Clear();LCD_pos(0,0); LCD_STR(txStrData);Init_USART0();putSTR_USART0(txStrData);SREG|=0x80;while(1);}
댓글 0
조회수 3,360등록된 댓글이 없습니다.