AnsweredAssumed Answered

BF592: non-blocking SPORT mode - burst transmission?

Question asked by Chrill on Oct 29, 2013
Latest reply on Nov 6, 2013 by randreol

Hi all,

 

I'm using BF592 (ez-kit) with cces 1.0.2.

I'm currently kind of struggling with a seemingly simple talkthrough problem: 

 

+ I'm reading ADC data via SPI

+ each SPI read (BF592 is master) is triggered by a timer IRQ

+ on every 4th timer IRQ I need to send data via SPORT to a DAC (2 x 3 bytes) - possibly with a high bitclock frequency

 

So basically what I'd like to do is bursting out some data on the SPORT - triggered by a timer IRQ.

What I did was this (I removed the less important parts for clarity):

 

bool timerFlag = false;
int channel = 1;

static void TimerHandler(void *pCBParam, uint32_t Event, void *pArg) {
          switch (Event) {
               case ADI_TMR_EVENT_IRQ:
                              timerFlag = true;
                              break;
               default:
                              break;
  }
}

int main(void)
{     


     uint8_t TxBuffer[2]  = {WRITE_CFR_DUMMY_LO,MANUAL_CHANNEL_ENBL};
     uint8_t RxBuffer[2]  = {0u,0u};
     ADI_SPI_TRANSCEIVER Transceiver1  = {NULL, 0u, &TxBuffer[0], 2, &RxBuffer[0], 2};
     uint8_t sportBuffer_li[SIZE_OF_TX_BUFFER] = {0x00, 0x00, SPORT_pre_li};
     uint8_t sportBuffer_re[SIZE_OF_TX_BUFFER] = {0x00, 0x00, SPORT_pre_re};

     /*setup SPI*/
     ...

     /*setup timer*/
     ...

     /*setup SPORT*/
     adi_sport_Open(0,ADI_SPORT_DIR_TX, ADI_SPORT_SERIAL_MODE, DeviceMemory,ADI_SPORT_DMA_MEMORY_SIZE,&hSPORTdevice);
     adi_sport_ConfigData(hSPORTdevice, ADI_SPORT_DTYPE_ZERO_FILL, false, 23u);
     adi_sport_ConfigClock(hSPORTdevice, 1u, true, bFallingEdge);
     adi_sport_ConfigFrameSync(hSPORTdevice, 24u, true, true, bDataIndi, bActiveLow, false);
     adi_sport_EnableDMAMode(hSPORTdevice,false);

     while(1){


          if (timerFlag){

               adi_spi_ReadWrite(hSPIdevice, &Transceiver1);

               switch (channel){
                    case 1:
                           sportBuffer_li[0] = RxBuffer[0];
                           sportBuffer_li[1] = RxBuffer[1];
                           break;
                     case 2:
                           sportBuffer_re[0] = RxBuffer[0];
                           sportBuffer_re[1] = RxBuffer[1];
                           break;
                     case 3:
                           /*ignore data of channel 3*/
                          break;
                     case 4:
                          /*ignore data of channel 4*/
                          break;
               }

               if(channel==4){
                   adi_sport_Enable(hSPORTdevice,false);
                   adi_sport_SubmitBuffer(hSPORTdevice,sportBuffer_li,SIZE_OF_TX_BUFFER);
                   adi_sport_SubmitBuffer(hSPORTdevice,sportBuffer_re,SIZE_OF_TX_BUFFER);
                   adi_sport_Enable(hSPORTdevice,true);
               }

               channel++;
               if (channel==5){
                  channel = 1;
               }

               timerFlag = false;

       }
    }
}

In principle this code works - the problem is that disabling/enabling the SPORT for each transfer takes too long such that the code block in

if (timerFlag) 
{
     ...
} 

cannot be processed in time, i.e. a new timer IRQ is already pending.

 

Is there a better way to implement burst transmission via SPORT (I wouldn't even care if the SPORT clock was running all the time)?

Can I somehow use adi_sport_GetBuffer() to get pointers to the SPORT buffers even if they are both empty?

 

Any hints are much appreciated!

 

Thanks,

Chris

Outcomes