본문 바로가기

임베디드/Atmega328p14

atmega328p 헤더파일 io.h 파일 로 가면 atmega328은 iom328p.h 파일을 참조 하라고 한다. 2020. 12. 28.
ATmega328p datasheet 2020. 12. 17.
16x2 8핀제어 데이터시트 그대로 적은 코드 /* * Main2.c * * Created: 2020-11-09 오전 10:29:49 * Author: User */ #define F_CPU 16000000UL #include #include #include #define LCD_DATAPORTD #define LCD_COMMANDPORTD #define LCD_CTRLPORTB #define LCD_RS 0 #define LCD_RW 1 #define LCD_EN 2 void lcdData(unsigned char data) { LCD_CTRL |= (1 2020. 11. 9.
16x2 lcd 4핀제어. 코드설명 필기 /* * main3_4pins.c * * Created: 2020-11-09 오후 1:57:06 * Author: User */ #define F_CPU 16000000UL #include #include #define LCD_DATA_DIRDDRD #define LCD_CTRL_DIRDDRB #define LCD_DATA_PORTPORTD #define LCD_CTRL_PORTPORTB #define RS PORTB0 #define EN PORTB1 void lcdComm(unsigned char cmd){ //상위 4비트 처리 LCD_DATA_PORT = (LCD_DATA_PORT & 0x0F) | (cmd & 0xF0); LCD_CTRL_PORT &= ~(1 2020. 11. 9.
16x2 LCD D0, D1 -> C 포트에 꼽은 코드 D0, D1이 RX, TX에 꽂혀있어서 업로드가 잘 안되는 듯함. rx tx 뽑아서 업로드 하고 꽂고 다시 업로드 하면 될때도 있고. 이렇게 여러번 해도 안될때도 있고. 꼽힌채로 업로드 해서 될 때 도 있음 -> rx tx를 C 포트에 꼽으면 되는가? 해서 아래 코드를 시도해봄 /* * LCD16x2.c * * Created: 2020-11-06 오후 2:00:16 * Author : User */ #include #define F_CPU 16000000UL #include #define RSPORTB0 #define RWPORTB1 #define EPORTB2 int main(void) { int r, c; char *string[] = {"1st line", "pin23"}; lcdInit(); fo.. 2020. 11. 7.
16x2 LCD (LC1621-SMLYH6) /* * LCD16x2.c * * Created: 2020-11-06 오후 2:00:16 * Author : User */ #include #define F_CPU 16000000UL #include #define RSPORTB0 #define RWPORTB1 #define EPORTB2 int main(void) { int r, c; char *string[] = {"1st line", "2nd line"}; lcdInit(); for (r=0; r 2020. 11. 6.
interrupt 2개 사용 LED 2개 제어 /* * 201105_interrupt.c * * Created: 2020-11-05 오전 9:37:16 * Author : User */ #include #include #define F_CPU 16000000UL // #define _BV(x)(1 1 any logical change // INT1 -> any logical change //EICRA |= _BV(ISC10); // INT0 //EICRA |= _BV(ISC00); // INT1 //EICRA = (_BV(ISC00)) | (_BV(ISC00)); //EICRA |= 5; //EICRA |= 0x05; EICRA |= 0b00000101; //Enable external interrupt 0 and interrupt 1 using t.. 2020. 11. 6.
interrupt 하나 사용 ,LED 하나 /* * 201105_interrupt.c * * Created: 2020-11-05 오전 9:37:16 * Author : User */ #include #include #define F_CPU 16000000UL // #define _BV(x)(1 1interrupt 2개 사용 LED 2개 제어/* * 201105_interrupt.c * * Created: 2020-11-05 오전 9:37:16 * Author : User */ #include #include #define F_CPU 16000000UL // #define _BV(x) (1 1 2020. 11. 5.
atmega 328p port ddrx 2020. 11. 4.
button 풀다운으로 연결하면 켜졌다가 버튼 누르면 꺼짐풀업으로 연결하면 꺼져있다가 버튼 누르면 켜짐#define F_CPU 16000000UL #include #define LED1PORTD6 #define LED2PORTD7 #define BUTTONPORTB0 uint8_t key_lock =0; int main(void) { DDRD = (1 2020. 11. 4.
arduino uno atmega pin map 2020. 11. 3.
201103_LedBlink.c / DDRx 펌웨어 = 데이터시트를 보면서 레지스터를 직접 제어 DDRx 레지스터는 입출력 설정 레지스터 0은 입력 1은 출력을 의미 " | " : 다른 설정들은 건드리지 않고 특정 값만 바꾸겠다는 의미 | 없으면 변수초기화하는것,, 싹 다 바꿈 PORTB |= 0 2020. 11. 3.
atmega328p datasheet 2020. 11. 3.
AtmelStudio7.0 설치 atmega 328개발환경 2020. 11. 3.