1549 SPI data capture

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

1549 SPI data capture

736 Views
eddiemallon
Contributor I

Hi

I am using a LPC159 using the SPI to receive data fro a AD7193, a 24bit ADC. What is happening is that after 24 clks, is the first 8 clks do not load anything, the next 8 clks load the hi bits and the last 8 clks load the mid bits. The lo bits are never read. If I add an additional 8 clks all 24 bits are read. This is not what the datasheet states. The bit of code for SPI capture is below and is essentially the same as the examples in the user manual. Also attached is an oscilloscope image.

Anyone have any idea?

Thanks

Eddie Mallon

 while(~LPC_SPI1->STAT & SPI_STAT_TXRDY);
 LPC_SPI1->TXDATCTL = SPI_TXDATCTL_LEN(7) | SPI_TXDATCTL_ASSERT_SSEL0;  
 while(~LPC_SPI1->STAT & SPI_STAT_RXRDY); 
 AD7193_rx_data_high  = LPC_SPI1->RXDAT;
 
 while(~LPC_SPI1->STAT & SPI_STAT_TXRDY);
 LPC_SPI1->TXDATCTL = SPI_TXDATCTL_LEN(7);  
 while(~LPC_SPI1->STAT & SPI_STAT_RXRDY); 
 AD7193_rx_data_mid  = LPC_SPI1->RXDAT; 

 while(~LPC_SPI1->STAT & SPI_STAT_TXRDY); 
 LPC_SPI1->TXDATCTL = SPI_TXDATCTL_LEN(7) |SPI_TXDATCTL_EOT;
 while(~LPC_SPI1->STAT & SPI_STAT_RXRDY);
 AD7193_rx_data_low = LPC_SPI1->RXDAT ;
 
 AD7193_rx_data = ((AD7193_rx_data_high <<(16) | (AD7193_rx_data_mid <<(8)))| AD7193_rx_data_low );
 AD7193_rx_data = AD7193_rx_data & 0x00ffffff;

DS0004.BMP

Labels (1)
0 Kudos
2 Replies

557 Views
AldoG
NXP TechSupport
NXP TechSupport

Hello,

 

In your scope of the frame I don't know which one is the data you are receiving from your ADC, so I'll suppose that in the frame you see first byte of the MISO is the data you expect from your ADC (Hi byte) and so on right?

Then yes there is a problem with the SPI, and if you can share which signal is MISO, MOSI and CLK it would help a lot.

 

If not, then you are processing the data in the wrong way, let's say that the first byte in MISO is thrash data, and the second byte corresponds to your ADC first byte, then in your code you'll need to ignore the first read of MISO, and take the second byte as your correct ADC first byte.

 

So the SPI is working as it should just the wrong way to process the bytes you are receiving from your ADC.

 

Hope this helps,

Regards,
Aldo.

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

557 Views
eddiemallon
Contributor I

I recently resurrected the project and resolved the issue. If anyone is interested I can publish the code and info.

0 Kudos