Timing of events in an ISR

Mark VanderVoord markvandervoord at yahoo.com
Mon Oct 18 20:59:50 UTC 2004


Some details:

I have a task with priority of 5 which runs every 2
msec (using RMS).  It sends out a couple bytes over
SPI, then waits for the response event.  The ISR sends
the event and clears the interrupt flag.  I have added
some additional instructions to toggle an output line
which I can measure with an oscilloscope (more on that
 below).  There are two other threads in the system. 
Both are low priority and neither are doing anything
stupid like shutting off interrupts, etc.

bool spi_read(uint16 data) {

   //copy my task id into a place the ISR can find
   rtems_task_ident(RTEMS_SELF,0,&rtn_task_id);
   
   //set output high
   GPIO_OUTSET = 1 << 20;

   //write spi data
   SPI_DATA_REG = data;

   //wait for event
   rtems_event_set rtn_event;
   rtems_event_receive(1,WAIT_FOR_ALL,0,&rtn_event);

   //set output low
   GPIO_OUTCLR = 1 << 20;

   //release SPI
   SPI_STATUS_REG = SPI_STATUS_D;

   return true;
}

rtems_isr spi_isr(rtems_vector_number vector) {
   
   GPIO_OUTCLR = 1 << 20;

   //set event and clear interrupt
   rtems_event_send(rtn_task_id,1);
   SPI_INT_REG = 2;

   GPIO_OUTSET = 1 << 20;
}

With the output toggles shown above, I get an edge for
my request to send, the ISR entry and exit (or close
to), and the task resume after it's wait.  I am also
capturing the spi clock transitions, so that I know
when the data starts and ends.

I added these after my last email.  This is what I
have found:

spi data complete to ISR:   141 usec
event send in ISR:           11 usec
task wake after send:         3 usec

So the delay definitely looks like it occurs between
the hardware event and the ISR being called.  Which
means that the issue must be in something my other
tasks are doing?

Mark S VanderVoord
Self-Guided Systems, LLC


		
_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com



More information about the users mailing list