본문 바로가기
프로그래밍/임베디드

[AVR] OR, AND 연산자를 통한 출력

by JR2 2021. 1. 2.

Atmel Studio (Microchip Studio)의 OUTPUT 방식이다.

 

--------------------------

사용 Chip : Atmega8 
사용 Program : Microchip Studio(Ver - 7.0.2542) 
                     Proteus 8 Professional

--------------------------

 

 

Atmel Studio Code :

#include <avr/io.h>
#define F_CPU 8000000UL
#include <util/delay.h>

#define  GLCD_CTRL_PORT PORTC
#define  GLCD_CPORT_DIR DDRC

#define RS PC0

int main(void)
{



	GLCD_CPORT_DIR = 0xFF;


    while (1) 
    {

		GLCD_CTRL_PORT |= (0<<RS);
		_delay_ms(1000);


		GLCD_CTRL_PORT |= (1<<RS);
		_delay_ms(1000);


		GLCD_CTRL_PORT |= ~(0<<RS);
		_delay_ms(1000);


		GLCD_CTRL_PORT |= ~(1<<RS);
		_delay_ms(1000);


		GLCD_CTRL_PORT &= (0<<RS);
		_delay_ms(1000);


		GLCD_CTRL_PORT &= (1<<RS);
		_delay_ms(1000);


		GLCD_CTRL_PORT &= ~(0<<RS);
		_delay_ms(1000);


		GLCD_CTRL_PORT &= ~(1<<RS);
		_delay_ms(1000);
    }
}

 

 

Actual Output (Proteus) :

 

GLCD_CTRL_PORT = (0<<RS);
GLCD_CTRL_PORT = (1<<RS);

 

GLCD_CTRL_PORT = ~(0<<RS);

 

GLCD_CTRL_PORT = ~(1<<RS);

 

GLCD_CTRL_PORT &= (0<<RS);
GLCD_CTRL_PORT &= (1<<RS);

 

GLCD_CTRL_PORT &= ~(0<<RS);

 

GLCD_CTRL_PORT &= ~(1<<RS);

 

댓글