This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

speed up the code

Hallo,
would be nice if someone could take a look on my code.
It's just a little toy to delay an analog signal.

How can i optimize the speed?

unsigned short int Buff[3200];
//*****************************************************
int main (void)
{
   *
   *
   *
   *
}
//*****************************************************
void FIQ_Handler()__fiq __ram       // Timer 1 => Fast Interrupt
{
  static unsigned int position;
  T1CLRI = 0;// Clear Timer1 Interrupt

  DAC0DAT = Buff[position] << 16;   // read from ring_buffer
  while (!ADCSTA){}                 // wait for AD conversion
  Buff[position] = ADCDAT >> 16;    // write to ring_buffer
  ADCCON = 0x6A3;                   // start a new AD conversation
  if (++position >= Buffer_length) position = 0;
}
//*****************************************************

I tested the speed of the code by doing some port-toggling and then oszilloscoping.
Unfortunately software seems to be the limiting element.

Should i use a pointer instead of the variable position?
But as i'am a relative beginner in C i tried but it didn't works in the wanted way :-(

Should i try to write the interrupt-routine in assembler?
Does anybody would like to give me some big hint?
I have no idea how to place the assembler routine inside the IRQ routine.

How can i tell the assembler routine where the Buff[3200] array is located?
How can i tell the assambler routine where the variable Buffer_length is located?

:-)

0