AnsweredAssumed Answered

SPI+DMA problem

Question asked by khal on Jan 6, 2012
Latest reply on Jan 6, 2012 by khal

Hi,

I am trying to setup an SPI+DMA communication between my BF592 and AD7689 (ADC). My main looks like:

 

//PLL Config
ADI_SYSCTRL_VALUES sys_cntrl_struct;

//ClkIn = 25MHz
sys_cntrl_struct.uwPllCtl = 0x1800;//VCO = 12*ClkIn = 300MHz
sys_cntrl_struct.uwPllDiv = 0x0002;//SClk = VCO/4 = 75MHz
sys_cntrl_struct.uwVrCtl = 0x70D0;

bfrom_SysControl( SYSCTRL_WRITE | SYSCTRL_PLLCTL | SYSCTRL_VRCTL | SYSCTRL_INTVOLTAGE, &sys_cntrl_struct, NULL);
ssync();

*pPLL_DIV = sys_cntrl_struct.uwPllDiv; //considering Anomaly No-05000440
ssync();

 

//GPIO configuration
*pPORTG_MUX = 0x0002;//Use pins for SPI1 (SSel1, SPI1CLK, SPI1MOSI, SPI1MISO)
*pPORTG_FER = PG13 | PG8 | PG9 | PG10;//Enable pins

 

//SPI1 configuration
//Each 16-bit Sample takes 17 SPICLK cycles
//Enable SSel1
//Master, 16-bit, active high SCK, hardware SSel
//MSB first, Enable MISO, SPI1 mode = Receive through DMA
*pSPI1_BAUD = SCLK_freq/(16* SPS);
*pSPI1_FLG |= FLS1;
*pSPI1_CTL = MSTR | EMISO | SIZE | TIMODE(2);

//SPI1 (DMA6) Interrupt configuration
*pSIC_IMASK0 |= 0x00004000;
register_handler(ik_ivg10, SPI1_DMA6_ISR);

 

//DMA6 configuration
//DMA Start Address = Receive buffer (DData)
//No of samples = length of DData
//Size of a sample = size of one DData word
//DMA interrupt after DMA transfer done enabled
//Write to memory, DMA word size is 16 bit
//Enable DMA
*pDMA6_START_ADDR = Ping;
*pDMA6_X_MODIFY= 2;
*pDMA6_X_COUNT = nSamplesADC;

//Send appropriate Config Word first time
*pSPI1_TDBR =  (AD7689_CFG << 2);

 

//Enable SPI, send CFG and receive ADC data through DMA5
*pSPI1_CTL |= SPE;
*pDMA6_CONFIG = DI_EN | SYNC | WNR | WDSIZE_16 | DMAEN;

 

while(1)
{
       idle();
}

Outcomes