This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

F28335 MCBSP as SPI inetfacing with AD1258

Other Parts Discussed in Thread: ADS1258

 

 

I m interfacing ADS1258 with f28335 via MCBSP.

code for interfacing is:

for(;;)
{
mcbsp_xmit(sdata1,sdata2);
while( McbspaRegs.SPCR1.bit.RRDY == 0 ) {} // Master waits until RX data is ready
rdata2 = McbspaRegs.DRR2.all; // Read DRR2 first.
rdata1 = McbspaRegs.DRR1.all; // Then read DRR1 to complete receiving of data
 delay_loop();
  asm(" nop"); // Good place for a breakpoint

}

code for configuration setting:

void init_mcbsp_spi()
{
// McBSP-A register settings
McbspaRegs.SPCR2.all=0x0000; // Reset FS generator, sample rate generator & transmitter
McbspaRegs.SPCR1.all=0x0000; // Reset Receiver, Right justify word, Digital loopback dis.
McbspaRegs.PCR.all=0x0F08; //(CLKXM=CLKRM=FSXM=FSRM= 1, FSXP = 1)
 McbspaRegs.SPCR1.bit.DLB = 0;
McbspaRegs.SPCR1.bit.CLKSTP = 2; // Together with CLKXP/CLKRP determines clocking scheme
McbspaRegs.PCR.bit.CLKXP = 0; // CPOL = 0, CPHA = 0 rising edge no delay
McbspaRegs.PCR.bit.CLKRP = 0;
McbspaRegs.RCR2.bit.RDATDLY=01; // FSX setup time 1 in master mode. 0 for slave mode (Receive)
McbspaRegs.XCR2.bit.XDATDLY=01; // FSX setup time 1 in master mode. 0 for slave mode (Transmit)

McbspaRegs.RCR1.bit.RWDLEN1=5; // 32-bit word
McbspaRegs.XCR1.bit.XWDLEN1=5; // 32-bit word

McbspaRegs.SRGR2.all=0x2000; // CLKSM=1, FPER = 1 CLKG periods
McbspaRegs.SRGR1.all= 0x000F; // Frame Width = 1 CLKG period, CLKGDV=16

McbspaRegs.SPCR2.bit.GRST=1; // Enable the sample rate generator
delay_loop(); // Wait at least 2 SRG clock cycles
McbspaRegs.SPCR2.bit.XRST=1; // Release TX from Reset
McbspaRegs.SPCR1.bit.RRST=1; // Release RX from Reset
McbspaRegs.SPCR2.bit.FRST=1; // Frame Sync Generator reset
}

Clock is fine.

CS is fine.

Data output is fine.

While AS1258 doesn't give stable data. I m reading the default register values but it returns some random values.

START pin on ADC is 1, PDWN=1, RESET=1,

DRDY signal is also a bit unstable. It goes low n high but its width varies.

I tried with single byte read, but same type of Output observed. I changed SCLK ferquency but no effect.

I also tried sending data on falling edge n receiving data on rising edge of SCLK without luck.

for 8-bit transmission, code is: 

for(;;)
{
  McbspaRegs.DXR1.all=0x0045;     // register read, reg. ID=5
while( McbspaRegs.SPCR1.bit.RRDY == 0 ) {} // Master waits until RX data is ready
  rdata1 = McbspaRegs.DRR1.all; // Then read DRR1 to complete receiving of data
 delay_loop();
  asm(" nop"); // Good place for a breakpoint

}

 XCOMPAND n RCOMPAND adjusted. RWRDLEN=0  &  XWRDLEN =0

Help me PLZZZZZZZZZZZZ.

I dont understand where is the problem??????????????????

 

 

 

 

 

 

 

 

 

 

 

 

  •  

    Hi

    Looks like you mean ADS1258 because AD1258 is not valid part number for ADI :)

     Have you look the random values returned from ADC in the  MCBSP registers or on the data line with scope?

    Anyway the problem is probably in the ADC not in the DSP. 

    Check if the data is stable on the RISING edge of the SCLK (both lines DIN and DOUT). Also check the SCLK frequency. It should not be above the 1/2 of the fclk (i.e. 8MHz for external or 7.86MHz for internal clock).

    Regards.

     

     

     

     

     

  • thank u for the reply. Yes it is ADS1258. 

    SCLK is lower than 7.86MHZ. it tried 2 MHZ & below.

    I checked the data on the scope , instead of returning 0xFFh for register 5, it returns values like, 13,69,113,212 etc & then actually sort of repeats the cycle & it looks like that these values are fixed for any command. 

    regarding timings, on page 6 of ADS1258 data sheet, in SCLK description,it is mentioned that the "SPI Interface Clock Input: Data clocked in on rising edge, clocked out on falling edge."

    If data from delfino f28335 is clocked out on rising edge and ADS1258 receives data on the rising edge also, isn't there be a conflict because ADC should receive valid data.

    waiting for ur relpy

    Abdul salam

     

     

     

      

     

     

     

  •  

    you are right. in the text of the datasheet its written the data clocked out on the falling edge. but on the figure 1 on the page 7 it rather valid on the rising edge. but probably the text is correct and the figure is not  very accurate. 

    try to check the time between CS goes low and first SCLK rising edge (it should be at least 2.5*TCLK). 

    Can you provide your scopes here? 

     

    may be  you  would also  ask your question on the Data Converters forum? 

    http://e2e.ti.com/support/data_converters/precision_data_converters/f/73.aspx

    regards.

    Roman