CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

fix time for the interrupt

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
viknes1985



Joined: 11 Nov 2008
Posts: 24

View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger

fix time for the interrupt
PostPosted: Wed Mar 11, 2009 2:50 pm     Reply with quote

hi,

i've some problem with interrupt. This what i wanted, i enable the interrupt, after it execute for X times, i disable it. So first i used a while loop to wait till the interrupt to be finish.

Code:
#int_RB
void reader(void)

     if (detector==0)
     {
      //set timer1
      detector++;  //detector =1
      break;
     }
 
     else if (detector == 1)
     {
       //set timer1, pause timer1, run timer1, reset timer1
      //and some other code
      detector = 2;
     }
     
     else if (detector == 2)
     {
        //if fullfill the condition always execute the code in detector = 2
         
       if (got error)
       detector = 0;
      
       if (finish execute for x times)
       {
        //disable interrupt
        flag = 1;
       }
     }
 }
 
}


void main(void)
{
  setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);
  enable_interrupts(global);
   
  while (1)
  { 
       flag = 0;
       RBIF = 0;
       RBIE = 1;
   
    while(!flag)
    {
    //do nothing, wait for flag equals 1
    }
   
   RBIE = 0;
   
    if(flag == 1)
    {
    //printf at here
    }
  }
 

}


i've timers in ISR which is running and stopping according to if and else condition. it seems like it take very long time to execute, basically i'm doing a manchester code reader, the codes are at http://www.ccsinfo.com/forum/viewtopic.php?t=38065&highlight=.

Getting the code should only take about less than 50 ms, so i replace

Code:

while(!flag)
    {
    //do nothing, wait for flag equals 1
    }


to

Code:

delay_ms(50)


still i couldn't get it run. Is it possible to idle the other process for 50ms and only run ISR. Or RTOS or HIGH priority is the only option i've? Thanks in advance
curious how to solve
Guest







how to solve it
PostPosted: Sat Mar 14, 2009 1:50 am     Reply with quote

Anyone know how to solve it?
Sydney



Joined: 13 Feb 2009
Posts: 71

View user's profile Send private message

PostPosted: Sat Mar 14, 2009 3:38 am     Reply with quote

You need to post a test program that will compile and run, exactly what it should do, and what the problem is. It looks like a bit of a sideways approach to a simple task to me.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group