BASIC4MCU | 질문게시판 | 8051 초보자질문입니다
페이지 정보
작성자 HanDong 작성일2019-06-15 15:32 조회4,229회 댓글1건본문
#include <io51.h>
#define L_PPI_A *((unsigned char*)0x1c008)
#define L_PPI_B *((unsigned char*)0x1c009)
#define L_PPI_C *((unsigned char*)0x1c00a)
#define L_PPI_CR *((unsigned char*)0x1c00b)#define D_PPI_A *((unsigned char*)0x1c014)
#define D_PPI_B *((unsigned char*)0x1c015)
#define D_PPI_C *((unsigned char*)0x1c016)
#define D_PPI_CR *((unsigned char*)0x1c017)#define R_PPI_A *((unsigned char*)0x1c01c)
#define R_PPI_B *((unsigned char*)0x1c01d)
#define R_PPI_C *((unsigned char*)0x1c01e)
#define R_PPI_CR *((unsigned char*)0x1c01f)#define TO_L_SHIFT 0x18
bit led1=P1.0;
bit led2=P1.1;
bit led3=P1.2;
bit led4=P1.3;
bit SW1=P1.4;
bit SW2=P1.5;
bit SW3=P1.6;
bit SW4=P1.7;void delay(int i)
{
while(i--);
}void busy_flag_check(void)
{
data unsigned char ir_value;
L_PPI_CR=0x92;
L_PPI_C=0xf3;
do{
L_PPI_C=0xf6;
ir_value=L_PPI_B;
L_PPI_C=0xf2;
} while(ir_value&0x80);
L_PPI_CR=0x90;
L_PPI_C=0xf3;
}void msg_cmd_write(unsigned char msg_cmd)
{
busy_flag_check();
L_PPI_C=0xf4;
L_PPI_B=msg_cmd;
L_PPI_C=0xf0;
L_PPI_C=0xf3;
}void msg_char_display(char write_char)
{
busy_flag_check();
L_PPI_C=0xf5;
L_PPI_B=write_char;
L_PPI_C=0xf0;
L_PPI_C=0xf3;
}void msg_string_display(char *write_string)
{
while(*write_string)
{
msg_char_display(*write_string);
write_string ++;
delay(500);
}
}void d_f (unsigned char pb_font)
{
int k;
for(k=0; k<8; k++)
{
D_PPI_A=0x00;
D_PPI_B=pb_font;
D_PPI_C=0x00;
delay(10000);
D_PPI_A=0xff;
D_PPI_C=0xff;
}
}void d_e(unsigned char pa_font)
{
int k;
for(k=0; k<8; k++)
{
D_PPI_A=pa_font;
D_PPI_B=0x00;
D_PPI_C=0x00;
delay(10000);
D_PPI_B=0xff;
D_PPI_C=0xff;
}
}void b_g (unsigned char pb_font)
{
int k;
int b = 0xf3;
for (k=0; k<8; k++)
{
D_PPI_A = 0x00;
D_PPI_B = pb_font;
D_PPI_C = 0x00;
delay(12500);
D_PPI_A = 0xff;
b = (b << 0x01);
D_PPI_C = 0xff;
}
}void p_c(unsigned char pc_ext)
{
R_PPI_B = 0xf0;
delay(10000);
}void p_e(unsigned char pe_ext)
{
R_PPI_B = 0x0f;
delay(10000);
}int lcd_r (unsigned char *l_r)
{
int k=0;
msg_cmd_write(0x80);
msg_string_display("Riding");
delay(10000);}
int lcd_p (unsigned char *l_p)
{
int k=0;
msg_cmd_write(0x80);
msg_string_display("Please");
msg_cmd_write(0xc0);
msg_string_display("Try Again");
delay(10000);
}
void main (void)
{
int k=0;
R_PPI_CR=0x80;
D_PPI_CR=0x80;
b_g(0xff);while(1)
{
if(SW1==1)
{
led3=0;
d_f(0xff);
R_PPI_B = 0xf0;
if(led1==1);
{
msg_cmd_write(0x80);
msg_string_display("Riding");
}
}else if(SW2==1)
{
led1=0;
d_e(0xff);
R_PPI_B = 0x0f;
if(led3==1);
{
msg_cmd_write(0x80);
msg_string_display("Please");
msg_cmd_write(0xc0);
msg_string_display("Try Again");
}
}else
{
P1=0xff;
R_PPI_B=0xff;
SW1=0xff;
SW2=0xff;
led1=1;
led2=1;
led3=1;
msg_cmd_write(0x01);
}
}
}
버스교통카드단말기를 만들려고 합니다.
현재 딥스위치 1번 동작을 함과 동시에
교통 카드가 태그되었다는걸 표현하였습니다.
LED Green lamp 점등
Dot matrix에 Green lamp 점등
릴레이에 Green lamp 점등
lcd 모니터에 Riding 표시
딥스위치 2번 동작을 함과 동시에
LED Red lamp 점등
Dot matrix에 Red lamp 점등
릴레이에 Red lamp 점등
lcd 모니터에 Please try agin 표시를 하였습니다.
현재 인터럽트부분 메인문을 작성을 하지 못하는 상태입니다.
제가 하고 싶은 동작은
먼저 딥스위치1번이 동작되어있는 상태에서 아무 현상도 나타나지 않습니다.
이때 인터럽트를 누르면 위의 딥스위치 1번 동작현상이 나타나고
딥스위치2번이 동작되어있는 상태에 아무 현상도 나타나지 않는 상태에서
인터럽트를 누르면 딥스위치 2번 동작현상이 나타나고
다시 인터럽트를 누르면 딥스위치 1번 동작현상이 나타나게 하고싶습니다.
댓글 1
조회수 4,229master님의 댓글
master 작성일
if(led1==1); <-------- 여기있는 세미콜론은 일부러 넣은걸까요?
{
msg_cmd_write(0x80); msg_string_display("Riding");
}
두 군데 정도 세미콜론 오류가 보입니다.