|
이전 질문 게시판은 새 글 쓰기를 막았습니다. [질문 게시판]을 이용바랍니다.
Date |
2008/06/12 21:55:48 |
Name |
NOksaNmaN |
Subject |
마이크로 프로세서 질문 좀 하겠습니다. |
#include <io51.h>
#define BYTE unsigned char
#define WORD unsigned int
#define PPA (*(BYTE*) 0x010000)
#define PPB (*(BYTE*) 0x010001)
#define PPC (*(BYTE*) 0x010002)
#define PPCR (*(BYTE*) 0x010003)
#define LCD_INST (*(BYTE*) 0x011000)
#define LCD_RD_BF (*(BYTE*) 0x011001)
#define LCD_WR_DATA (*(BYTE*) 0x011002)
#define LCD_RD_RAM (*BYTE*) 0x011003)
#define LED9 T0
#define NULL 0
#define DAC_WRITE (*(BYTE*) 0x014000)
#define CT_2ms -1843
#define Control_word 0x88
#define seg_font_jum 0x80
int int_time_flag=1, int_count=0;
WORD CT_timeset;
BYTE DAC_data;
BYTE baekjari, sibjari, iljari;
const BYTE seg_font[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x27,0x7f,0x6f};
BYTE seg_scan[]={0x01,0x02,0x04};
BYTE seg_data[3];
int scan_count=0;
int i;
BYTE led;
BYTE busy=0;
delay(WORD j)
{
WORD i;
for(i=0; i<j; i++);
}
void LCD_busy_check()
{
BYTE i;
for(i=0;i<2000;i++)
{
busy=LCD_RD_BF & 0x80;
P1=busy | 0x7F;
if(busy==0) return;
}
}
void LCD_initial()
{
delay(600);
LCD_INST=0x30;
delay(400);
LCD_INST=0x30;
LCD_busy_check();
LCD_INST=0x38;
LCD_busy_check();
LCD_INST=0x0c;
LCD_busy_check();
LCD_INST=0x01;
LCD_busy_check();
LCD_INST=0x06;
}
void LCD_instruction(char haeng, char yul)
{
LCD_busy_check();
switch(haeng)
{
case1:LCD_INST=0x80+yul;
case2:LCD_INST=0xc0+yul;
}
}
void LCD_munja(BYTE ch)
{
LCD_busy_check();
LCD_WR_DATA=ch;
}
void LCD_munjayul(char *str, char haeng, char yul)
{
BYTE i=0;
LCD_instruction(haeng,yul);
for(;;)
{
delay(500);
LCD_munja(str[i]);
if(str[++i]==NULL)break;
}
}
void init_timer()
{
TMOD=0x00;
TL0=CT_2ms & 0xff;
CT_timeset=CT_2ms <<3;
TH0=CT_timeset >>8;
TR0=1;
ET0=1;
}
void hexTOdec(BYTE hex)
{
WORD temp;
BYTE junsu, sosujari;
temp=hex*10;
junsu=(temp*5)/256;
iljari=junsu/10;
sosujari=junsu-(iljari*10);
seg_data[0]=seg_font[iljari & 0x0f];
seg_data[1]=seg_font_jum;
seg_data[2]=seg_font[sosujari & 0x0f];
}
void main()
{
init_timer();
EA=1;
PPCR=Control_word;
{
BYTE key_in, key_out=0x0e, pyosi_data, hkey_bit,lkey_bit;
PPCR=0x88;
P1=0xff;
led=0xfe;
LCD_initial();
PPA=0xcf;
LCD_munjayul("3.7",2,2);
}
while(1)
{
P1=0xc8;
for(scan_count=0; scan_count<3; scan_count++)
{
PPA=seg_data[scan_count];
PPB=seg_scan[scan_count];
delay(20);
}
}
}
interrupt [0x0B] void T0_int (void)
{
TL0=CT_2ms &0x1f;
CT_timeset=CT_2ms <<3;
TH0=CT_timeset >>8;
int_count++;
if(int_count>500)
{
DAC_data=0xc0;
DAC_WRITE=DAC_data;
delay(50);
hexTOdec(DAC_data);
int_count=0;
}
}
=====================================================
제가 c언어를 너무 모르는 상태에서 나름 열심히 짠 프로그램인데요 .
세그먼트에 3.7이라는 숫자가 나오게 하고 그 결과가 led에도 나오게 해야 하는데요.
강제적으로 나오게 하는게 아니라 결과를 따와서 출력하게끔.
고수분들이 좀 도와주셨으면 좋겠습니다.
틀린부분 지적도 해주셨으면 감사하겠습니다.
|
통합규정 1.3 이용안내 인용
"Pgr은 '명문화된 삭제규정'이 반드시 필요하지 않은 분을 환영합니다.
법 없이도 사는 사람, 남에게 상처를 주지 않으면서 같이 이야기 나눌 수 있는 분이면 좋겠습니다."
|