[PR] 仕事求人 グアム格安旅行 求人・転職 seo対策 CIA
teacup. ] [ 掲示板 ] [ 有料掲示板 ] [ みんなの掲示板 ] [ ブログ ] [ チャット ]

新着順:9/83 記事一覧表示 | 《前のページ | 次のページ》

fjcニュ-ス11月号 2/2

 投稿者:山原  投稿日:2008年10月30日(木)14時21分41秒
  通報
  /*p8 bit 7 LED &LCD  0-3 DB4-7 OUT E bit4 RS bit6  */
void init_lcd(void)
{
  tmx=15;
  wait_ms();
  IO.PDR8.BIT.B6=0; /* RS= L */
  d8=0x3;
  wr_ld8();
  tmx=5;
  wait_ms();
  d8=0x3;
  wr_ld8();
  tmx=100;
  wait_us();
  d8=0x3;
  wr_ld8();
  d8=0x2;
  wr_ld8();
  d4=0x28;
  wr_ld4;
  d4=1; /* clr command */
  wr_ld4();
  tmx=2;
  wait_ms();
  d4=0x6; /* entry mode set */
  wr_ld4();
  d4=0xe; /* dsplay & cursor on */
  wr_ld4();
}
void wr_ld8(void)
{
  tmy=IO.PDR8.BYTE;
  tmy=tmy & 0xf0;
  tmy=tmy + d8;
  IO.PDR8.BYTE=tmy;
  wait_n();
  IO.PDR8.BIT.B4=1;   /*E = H */

  wait_n();
  IO.PDR8.BIT.B4=0;   /*E = L */
  tmx=80;
  wait_us();
}
void wait_n(void)
{
  tmy=tmy;
}
void wr_ld4(void)
{
  d8=d4 & 0xf0;
  if(d8 > 0xf )d8=d8/0x10;
  wr_ld8();
  d8=d4;
  d8=d8 & 0xf;
  wr_ld8();
}
/* 時計LCD表示 */
void dsp_wath(void)
{
  IO.PDR8.BIT.B6=0; /* RS= L */
  d4=0x80; /* cursor top */
  wr_ld4();
  IO.PDR8.BIT.B6=1; /* RS= H */
  d4=DD[5]+0x30; /* time*10 */
  wr_ld4();
  d4=DD[4]+0x30; /* time */
  wr_ld4();
  d4=':'; /* time */
  wr_ld4();
  d4=DD[3]+0x30; /* min*10 */
  wr_ld4();
  d4=DD[2]+0x30; /* min */
  wr_ld4();
  d4=':'; /* min */
  wr_ld4();
  d4=DD[1]+0x30; /* sec * 10 */
  wr_ld4();
  d4=DD[0]+0x30; /* min */
  wr_ld4();
}
void wait_ms(void)
{

    tmx=tmx*2800; /* if tmx=2800 then 1ms Wait */
    for ( tmy=0;tmy < tmx;tmy++);
}
void wait_us(void)
{

    tmx=tmx*3; /* if tmx=2.8 then 1us Wait */
    for ( tmy=0;tmy<tmx;tmy++);

}
#pragma interrupt(tmai)
void tmai(void)
{
  char i,j;
IENR1.BIT.IENTA = 0 ; /* disable Timer A overflow interrupt */
IRR1.BIT.IRRTA = 0 ; /*オバーフローフラグクリア*/
j=0;
DD[0]=DD[0]+1;
  if(DD[0]==10){
   DD[0]=0; /* sec */
   DD[1]=DD[1]+1;
   if(DD[1]==6){
   j=1;
   DD[1]=0;
   DD[2]=DD[2]+1;
   }
   if(DD[2]==10){ /* min */
   DD[2]=0;
   DD[3]=DD[3]+1;
   }
   if(DD[3]==6){
   DD[3]=0;
   DD[4]=DD[4]+1;
   }
   if(DD[4]==10){
   DD[4]=0; /* time */
   DD[5]=DD[5]+1;
   }
   if((DD[5]==2) && (DD[4]==4)){
   DD[5]=0;
   DD[4]=0;
   }
   }
   if(j == 1){
   i=5;
lp: rsout(DD[i]+0x30);
   i--;
   if(i==3)rsout(':');
   if (i > 1)goto lp;
   }
   if((DD[0] & 1) == 0){
      IO.PDR8.BIT.B7=0; /* LED ON */
      }
   else{
      IO.PDR8.BIT.B7=1; /* LED OFF */
      }
   dsp_wath();
   IENR1.BIT.IENTA = 1 ; /* enable Timer A overflow interrupt */
  }

http://homepage2.nifty.com/JG1FJC/

 
》記事一覧表示

新着順:9/83 《前のページ | 次のページ》
/83