메뉴 바로가기

서브메뉴 바로가기

본문 바로가기

logo

묻고 답하기
러빙유2008.01.09 16:21

주인장님..제안하신 구조로 했는데, 인터럽트 주기 타임이 150us 까지 내려갔습니다.

기존의 isr에 구현할 때는 2ms면 충분했는데, 150us정도 되어야지 fnd,led가 깜빡이지 않고 들어옵니다.

첫번째 Disp_operation() 만 while에서 돌릴때는 1ms 만 되어도 잘 들어오느데, 갑자기 SW_operation()

이 들어가니 150us가지 가야 되고 맙니다.

맞는 건지...ㅜㅜ

코드를 첨부합니다.

#pragma vector = TIMER0_COMP_vect  //1ms interrupt isr
__interrupt void timer0_compare_isr(void)

{    
      if(Disp_timer) Disp_timer--; //fnd,led timer
      if(LED_timer) LED_timer--;//LED blink timer
      if(Key_timer) Key_timer--; //key input timer       
}

void Disp_operation(void) {
 
  if(Disp_timer>0) return;
 
  Disp_timer =1;
 
      DIGM = 1<<icounter;
        ////////////////////////////
        if(icounter == 3){
          if(blink_flag >0 && blink_flag < 9){
              if(LED_timer>0) return;
             
              LED_timer = 800;
                if(LEDST[blink_flag-1]==1){ //LED OFF
                Led_one = Led_one & ~(1<<(blink_flag-1));//ON  
                SEGM = Led_one;}
                else if(LEDST[blink_flag-1]==0) { //LED ON
                Led_one = Led_one | (1<<(blink_flag-1));//OFF
                SEGM = Led_one;}               
          }
          else {
            SEGM = Led_one; }
        }
        ////////////////////////////// 
        else if(icounter == 7){
          if(blink_flag >8){
              if(LED_timer>0) return;
             
              LED_timer = 800;
                if(LEDST[blink_flag-1]==1){ //LED OFF
                Led_two = Led_two & ~(1<<(blink_flag-9));//ON  
                SEGM = Led_two;}
                else if(LEDST[blink_flag-1]==0) { //LED ON
                Led_two = Led_two | (1<<(blink_flag-9));//OFF
                SEGM = Led_two;}               
          }
          else {
            SEGM = Led_two; }
        }
        ////////////////////////////////
        else{SEGM =fnd_data[icounter];}
   ++icounter;
   if(icounter ==8) icounter=0;
}   

void SW_operation(void) {
  if(Key_timer>0) return;
 
  Key_timer =1;
  key = KEYM;
 
       if(key&0xff == 0xff){
          if(key_flag==0) return;
             else{
                if(++key_counter==4){
                    key_flag=0;
                    key_counter=0;
                    return;
                 }
             }
        }
        else{
           if(key_flag==0){
              if(++key_counter==4){
                 key_flag=1;
                 key_counter=0;
                 sw_input=key;
                 return;
              }
           } 
           
            else return;
        }


------------------------------------------------------------------------------
main while 입니다.

while(1) {
Disp_operation();
SW_operation();

  }

사진 및 파일 첨부

여기에 파일을 끌어 놓거나 왼쪽의 버튼을 클릭하세요.

파일 용량 제한 : 0MB (허용 확장자 : *.*)

0개 첨부 됨 ( / )