QSPi in interrupt

Discussion to talk about software related topics only.
Post Reply
chrispol
Posts: 30
Joined: Mon Mar 08, 2010 8:46 am

QSPi in interrupt

Post by chrispol »

Is it possible to use qspi in an interrupt?

code snippet causes an exception, reading from a 3201

Code: Select all

  
SHORT ReadADC()
{
  BYTE  l_data[2];
  SHORT l_value;

  OS_SEM QSPI_SEM;

  OSSemInit(&QSPI_SEM, 0);
  QSPIStart( NULL,&l_data[0], 2, &QSPI_SEM );
  OSSemPend( &QSPI_SEM, 0 );

  l_value = ((l_data[0]<<8)|l_data[1]) & 0x0FFF;

  return l_value;
}

INTERRUPT(XAxisTimer,0x2400)
{
  USER_ENTER_CRITICAL();

  WORD tmp = sim.pit[1].pcsr;
  tmp &= 0xFF0F;
  tmp |= 0x0F;
  sim.pit[1].pcsr = tmp;

  SHORT l_val = ReadADC();

  USER_EXIT_CRITICAL();
}
rsg
Posts: 54
Joined: Thu May 15, 2008 5:36 am

Re: QSPi in interrupt

Post by rsg »

No, you cannot pend on anything in an ISR. Basically, you only want to trigger tasks in an ISR; tasks are free to pend as necessary.

Also, you code will initializes the semaphore many times - you should only call OSSemInit once.
chrispol
Posts: 30
Joined: Mon Mar 08, 2010 8:46 am

Re: QSPi in interrupt

Post by chrispol »

Ok right now i am using my timer for stepper timing on movement, and i have to make an adc reading for each step.

so i guess in my main function i would have to check a flag that the interrupt sets to take a step then read the adc?
User avatar
pbreed
Posts: 1088
Joined: Thu Apr 24, 2008 3:58 pm

Re: QSPi in interrupt

Post by pbreed »

For doing this sort of thing I talk directly to the QSPI hardware not the QSPI library.
Take a look at the Freesscale Manual, you can set it up so QSPI continiously updates values from the A/D then just read a register, no pending.

Paul
User avatar
lgitlitz
Posts: 331
Joined: Wed Apr 23, 2008 11:43 am
Location: San Diego, CA
Contact:

Re: QSPi in interrupt

Post by lgitlitz »

Paul is correct here. You should just set up the A2D to work in continuous mode so it is always reading form the A/D. There is no need to pend since the QSPI data registers are already holding fresh data that is less then 1uS old. Since the QSPI is in continuous (looping) mode there is no CPU interaction required except when you want to read a result, no interrupt required.

I am attaching some a driver I did for a board that had 2 TI TLV2548 A/Ds. So 2 8-channel A/Ds gave me 16-channels of A/D data. I have the QSPI running in continuous mode where each channel will be stored in one of the 16 data queues on the QSPI peripheral. Then when I want to get data I disable the QSPI, read the data from the corresponding channels QSPI queue and then re-enable the QSPI peripheral. Not sure if this code is completely bug free but it should give you a good starting point.

-Larry
Attachments
TI_A2D_TLV2548.zip
Reading from 2 TI TLV2548 A/Ds via QSPI running in continuous mode.
(2.15 KiB) Downloaded 375 times
Post Reply