반응형
Atmega8a
8MHz Ext.OSC
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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | /* * Study_Atmega8A.c * * Created: 2018-12-18 오후 10:30:25 * Author : HeungSik */ #include <avr/io.h> #define F_CPU 8000000 #define FOSC 8000000 #include <util/delay.h> #define BAUD 9600 #define MYUBRR FOSC/16/BAUD-1 void init_serial(); void USART_Transmit(unsigned char data); unsigned char USART_Receive( void ); void init_serial(unsigned int ubrr){ UBRRH = (unsigned char)(ubrr >>8); UBRRL = (unsigned char)ubrr; //UBRRL = 25; /* Enable receiver and transmitter */ UCSRB = (1<<RXEN)|(1<<TXEN); /* Set frame format: 8data, 2stop bit */ UCSRC = (1<<URSEL)|(1<<USBS)|(3<<UCSZ0); } void USART_Transmit( unsigned char data ) { /* Wait for empty transmit buffer */ while ( !( UCSRA & (1<<UDRE)) ) ; /* Put data into buffer, sends the data */ UDR = data; } unsigned char USART_Receive( void ) { /* Wait for data to be received */ while ( !(UCSRA & (1<<RXC)) ) ; /* Get and return received data from buffer */ return UDR; } void Transmit_Line(char *string){ int i =0; while (*string != 0x00) { USART_Transmit(*string); i++; } } int main(void) { init_serial(MYUBRR); while (1) { USART_Transmit('a'); _delay_ms(50); } } | cs |
다음은 BLE모듈 사용하여 LED 제어하기
반응형
'Study > 8-bit MCUs' 카테고리의 다른 글
[AVR] Atmega128 + ds3231 + char LCD 시계 (0) | 2019.01.28 |
---|---|
Atemga128 ADC 참고자료 (0) | 2019.01.07 |
[Piano Board] AVR - Atmega128 프로젝트 (Piano만들기) 기능구현 완료 수정 필요 (0) | 2018.09.13 |
[Piano Board] AVR - Atmega128 프로젝트 (Piano만들기) 진행중 (0) | 2018.09.12 |
[Piano Board] AVR - Atmega128 프로젝트 (Piano만들기) 미완성 (0) | 2018.09.11 |