|
|
View previous topic :: View next topic |
Author |
Message |
viknes1985
Joined: 11 Nov 2008 Posts: 24
|
fix time for the interrupt |
Posted: Wed Mar 11, 2009 2:50 pm |
|
|
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
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 |
Posted: Sat Mar 14, 2009 1:50 am |
|
|
Anyone know how to solve it? |
|
|
Sydney
Joined: 13 Feb 2009 Posts: 71
|
|
Posted: Sat Mar 14, 2009 3:38 am |
|
|
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. |
|
|
|
|
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
|