Reading data in to microcontroller using SPI

Discussion in 'Embedded Systems and Microcontrollers' started by Samyukta Ramnath, May 21, 2015.

  1. Samyukta Ramnath

    Thread Starter New Member

    May 21, 2015
    12
    0
    I am using SPI to send data from an analog front end to a microcontroller and would like to be able to receive the data. Before receiving the data, I send data to the AFE to set certain registers in the AFE and would like to read the received data on the SIn pin on the microcontroller.

    I am unable to understand where exactly to do this reading and how to do it. I read that received data is read using the POPR command, but would I do this after having set all the required registers in the AFE? Or while setting the registers? Also, it says that I must read 2 bytes of data at a time on every clock pulse. Does this mean that to read 8 bytes of data, I must use the POPR command 4 times in succession?
     
  2. MrChips

    Moderator

    Oct 2, 2009
    12,449
    3,365
    You are missing some important information.
    What is the model number of the AFE?
    What is the model number of the microcontroller?
     
  3. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,397
    497
    Can I see block diagram?
     
  4. Samyukta Ramnath

    Thread Starter New Member

    May 21, 2015
    12
    0
    I am using a Kinetis K53 tower microcontroller and an ADAS1000sdz Analog Devices Front End.
     
  5. Samyukta Ramnath

    Thread Starter New Member

    May 21, 2015
    12
    0
    I am using SPI to send data from an analog front end to a microcontroller and would like to be able to receive the data. Before receiving the data, I send data to the AFE to set certain registers in the AFE and would like to read the received data on the SIn pin on the microcontroller. I am using a Kinetis K53 tower microcontroller and an ADAS1000sdz Analog Devices Front End.

    I have to send command words to the AFE to set control registers in it that tell me what data is to be sent and at what rate. To do this, I am pushing the command words into the TX FIFO. I can see that there is data in the TX FIFO consistent with what I have sent. I can see the TCR counter incrementing. Every control bit is 32 bits, including the address of the control register in the AFE. I have set the frame size to 8 bits- which means, that to send one control word, I must send 8 bits at a time. This corresponds to 4 SPI0_PUSHR commands for one control register. At every PUSHR, I am also doing POPR, to check what data is getting received.

    However at no point during the setting of the 4 control registers in the AFE, am I ever receiving any data in the RX FIFO.

    Also, I understand that only after setting the control registers in the AFE, will I be able to get the sampled data from the AFE to the microcontroller. So after setting four control registers, which corresponds to 16 PUSHR commands in total, I should read the relevant received data from the AFE. However, the RX FIFO is again read byte-by-byte; so how would I read the received data?

    If the data is streaming continuously, how would I know where one frame of data begins and one frame ends? I have set the incoming sampling rate at the time of setting the control registers present in the AFE.

    Edit : I am setting in the ADAS1000SDZ, a FRAMES register to issue the command to read the data. According to the datasheet, writing to the frame header register issues the read command to start putting the converted data out on the SDO pin.

    I tried the example given in the ADAS1000SDZ datasheet, which is to generate a 150Hz sine tone, and still didn't receive any data in the RX FIFO registers after the write.
    How do I read the registers that are read-only? How do I access the data there? For example, there are a number of registers at certain addresses which are supposed to have data. How do I read them?
     
Loading...