AnsweredAssumed Answered

spi program for BF592

Question asked by Fundoo on Mar 18, 2013
Latest reply on Apr 2, 2013 by Andreas

Hi All!!

 

I wrote a code to interface AD7276 to BF592 via SPORT interface but the code is not working.Can someone help me debug the code.

 

CODE:

 

#include<cdefbf592-A.h>

#include<sysreg.h>

#include<ccblkfn.h>

#include <sys\exception.h>

#include<stdio.h>

 

 

#define Size 0x2000

#define ADC_CONFIG_WORD  (0x3C49<<2);

 

 

short ADC_Samples[Size];

 

 

EX_INTERRUPT_HANDLER(SPORT0_Rx_ISR);

 

 

int i =0;

 

void main()

 

 

{

 

          //change PLL

 

          *pPLL_CTL = 0x2000;

          asm("idle;");

          *pPLL_DIV = 0x4;

          asm("ssync;");

 

 

          //SPORT Pin Mux config

          *pPORTG_MUX = 0;

          *pPORTG_FER = 0x00FF;

 

 

 

          //enable SPORT Rx interrupts

          register_handler(ik_ivg9, SPORT0_Rx_ISR);

          *pSIC_IMASK0 = IRQ_DMA1;

          ssync();

 

 

          //Init SPORT

 

          *pSPORT0_TCLKDIV = 12;

          *pSPORT0_TFSDIV = 35; //should be greater than 16 bit + time for conversion

 

 

          *pSPORT0_RCR2 = SLEN(15);

          *pSPORT0_RCR1 = DTYPE_NORM | LRFS | LARFS | RFSR | IRFS | IRCLK;

 

          *pSPORT0_TCR2 = SLEN(15);

          *pSPORT0_TCR1 = ITFS | DITFS | ITCLK | TFSR | LTFS | LATFS | TCKFE | DTYPE_NORM;

          //enable Gated Clock

          *pSPORT_GATECLK = 0x0001;

 

          //enable SPORT and then TIMER

 

          *pSPORT0_RCR1 |= RSPEN;

          *pSPORT0_TCR1 |= TSPEN;

 

 

          //Since TX Buffer is empty when SPORT is enabled, send the Config Word.

          //you can check if buffer is empty and then send the config word also.

          *pSPORT0_TX16 =  ADC_CONFIG_WORD;

 

 

          while(1)

          {

 

          }

 

 

}

 

 

 

 

/****************************************************************************************/

 

 

 

 

void SPORT0_Rx_ISR()

{

 

          ADC_Samples[i] = *pSPORT0_RX16;

          i++;

          if(i == Size)

          {

                    printf("\n Samples accumulated \n");

                    //disable SPORT

                    *pSPORT0_RCR1 |= ~RSPEN;

                    *pSPORT0_TCR1 |= ~TSPEN;

          }

 

 

}

 

 

 

/****************************************************************************************/

 

Thanks!!

Outcomes