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.

TM4C123GH6PZ: problem with SPI connection between microcontroller and ADS1292R

Part Number: TM4C123GH6PZ
Other Parts Discussed in Thread: ADS1292R,

Hello.

I have the following problem. The code I wrote for communicating between TM4C123GH6PZ and ADS1292R via SPI doesn't work. I am trying to read the ECG and respiration data from the ADS1292R (slave) and then send it through the UART, but I'm getting only zeroes, and not the actual data. I also tried to read the WHOAMI (ID) pin, but it reads as 0. I tried measuring the signals with a logic analyzer, but the results are not what I expected. For starters, the clock's frequency is 50kHz (even though in the code I've set the frequency to 1MHz) and the CS pin doesn't go down every time it should. Also, when I set the CPOL = 0 and CPHA = 1 in the settings, Saleae reports an error "The initial (idle) state of the CLK line does not match the settings.", but when I set CPOL = 1 it reades '255' on both transmitter and reciever, even though it's not supposed to. In ADS1292R datasheet it says the correct settings are CPOL = 0 and CPHA = 1, so I set SSI_FRF_MOTO_MODE_1 in SSI configuration. I am using Arduino Library for ADS1292R Shield/Breakout which I adapted so it fits my TM4C uC.

All this confuses me since I'm new to working with microcontrollers and I would really appreciate some help. I'm not even sure if the problem is with the software or hardware. In the attachment I put the whole project (folder: 'project'), the results from Saleae (folder: 'SALEAE SAMPLES'), the scheme of connecting the pins I used (folder: 'Scheme') and the Arduino Library for ADS1292R Shield/Breakout (folder: 'arduino_library').

Best regards,
Laura

3757.project.zip

  • May I applaud your, "Provision of measurements & procedures" which extend "so far" beyond the (usual) "Does Not Work!" (always delightful, that!)

    That said - your "Saleae files" are suffixed, "LogicData" - thus we cannot (easily) open. (Not all here are familiar w/that particular disty)

    I'm travelling - will review your code (if still required) later this day/night - yet suggest that you (really) review the multiple SPI code examples - the inability to set SPI clock frequency is "infrequently" noted - almost certain to result from a coding error...
  • Hi there,

    From this "blind" perspective: if your clock was expected to be 1MHz and you are getting 20 times slower... let's start by making sure you are configuring your SPI clock source correctly.

    Take a look at your SPI configuration. If you want, paste it here.

    For further readers, "Saleae" is a logic analyzer brand, they have an open source visualization software - so I assume that the originally attached files can be seen if one installs such viewer (which not many would be willing to do into a production machine...)

    Other hint: don't let the SPI hardware control your CS line. Handle it via regular GPIO.

    Since I have a piece of working SPI code right in front of me, it won't hurt to paste it for reference (although the configuration part ain't here):

        GPIOPinWrite(gyroHW->GPIOFSSPort,gyroHW->GPIOFSSPin,0);				// Lower CSB
        SSIDataPut(gyroHW->SSIBase, frameHigh);						// Sends only the upper 16 bits
        while(SSIBusy(gyroHW->SSIBase));							// Flush first 16 bits
        SSIDataGet(gyroHW->SSIBase, &readCrap);						// Read useless data
        SSIDataPut(gyroHW->SSIBase, (frameLow));						// This sends the other 16 bits
        while(SSIBusy(gyroHW->SSIBase));							// Flush second 16 bits
        GPIOPinWrite(gyroHW->GPIOFSSPort,gyroHW->GPIOFSSPin,gyroHW->GPIOFSSPin);	// Raise CSB
        SSIDataGet(gyroHW->SSIBase, &readCrap);						// Read useless data
        GPIOPinWrite(gyroHW->GPIOFSSPort,gyroHW->GPIOFSSPin,0);				// Lower CSB
        SSIDataPut(gyroHW->SSIBase, frameHigh);						// Flush third 16 bits
        while(SSIBusy(gyroHW->SSIBase));							// Wait for bits to be flushed out
        SSIDataGet(gyroHW->SSIBase, &read16High);						// Read 16 bits
        SSIDataPut(gyroHW->SSIBase, frameLow);						// Flush last 16 bits
        while(SSIBusy(gyroHW->SSIBase));							// Wait for bits to be flushed out
        SSIDataGet(gyroHW->SSIBase, &read16Low);						// Read more data
        GPIOPinWrite(gyroHW->GPIOFSSPort,gyroHW->GPIOFSSPin,gyroHW->GPIOFSSPin);	// Raise CSB
    

    Cheers

    Bruno

  • Thank you both for a fast reply.

    Today I tried running the code on a TM4C123G LaunchPad™ Evaluation Kit (which is not connected to the ADS1292R) for debbuging purposes and measuring with a logic analyzer to see if I'm sending the data correctly from the master (the pins on the other board are not easy to probe with the analyser). After some tinkering with the code, this is an example of what I'm sending through the MOSI line: http://imgur.com/W59EhCe
    Is it supposed to look like that? It seems okay to me, the data on the MOSI line matches what I'm sending in the code and the clock is fine and showing 1MHz on the LaunchPad.
    Tommorow I'll try to run the 'fixed' code on the other board and get back to you.

    Cheers!

    Laura
  • Laura,

    That's "kind of" how it is supposed to look like. It's just great to work with proper tools, ain't?

    Do you have an additional channel on your Saleae? Looking at the CS line is also important.

    I see some MOSI activity before the clock, that's suspicious.

    Here's a 4 channel capture for one particular sensor, it might help you.

    Bruno

  • Bruno,

    I was looking at the CS line as well, it's on channel 3:

    Just like the last example, his was measured on the Tiva LaunchPad which is not connected to the slave. There's MOSI activity before and after the clock, if that's a problem how do I fix it? It doesn't seem to bother Saleae since it deciphers the sent data correctly, I am really am trying to send 0xFF 9 times (as dummy data). Could those be start and stop bits? In the example you've sent me there also seems to be some activity on D2 channel while clock is inactive.

    This is the function I use to get data from the ADS1292R:

    char* ads1292r::ads1292_Read_Data()
    
    {
    
    uint32_t pui32Data;
    
    static char SPI_Dummy_Buff[10];
    
    
     GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_0, 0x00); // pulling CS low
    
    for(int j=0; j < 1000; j++); // wait a while
    
    for (int i = 0; i < 9; ++i)
    
    {
    
    SSIDataPut(SSI0_BASE, 0xFF); // send dummy data to the slave
    
    SSIDataGet(SSI0_BASE, &pui32Data); // get data
    
    SPI_Dummy_Buff[i] = pui32Data;
    
    }
    
     //digitalWrite(ADS1292_CS_PIN, HIGH);
    
    for(int j=0; j < 1000; j++); // wait a while
    
    GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_0, GPIO_PIN_0); // pull CS back up
    
    return SPI_Dummy_Buff;
    
    }


    Is this a correct way for getting data from the ADS1292R?
    I tried running the code on the other board (the one with the TM4C123GH6PZ and ADS1292R chip) but the data I'm getting seems like rubbish. I'm supposed to be getting 3 status bytes, then 3 respiration bytes and 3 ecg bytes, MSB first. Here are some examples of what i get when i print SPI_Dummy_Buff array:

    0 0 127 255 255 127 255 255 192
    0 0 127 255 255 127 255 255 192
    0 0 128 0 0 127 255 255 192
    0 0 50 160 93 127 255 255 192
    0 0 128 0 0 127 255 255 192
    0 0 192 62 125 127 255 255 192
    0 0 128 0 0 127 255 255 192
    0 0 127 255 255 127 255 255 192
    0 0 128 0 0 127 255 255 192
    0 0 127 255 255 127 255 255 192
    0 0 128 0 0 127 255 255 192
    0 0 127 255 255 127 255 255 192

    Cheers,

    Laura

  • Hi there,
    Can't help too much today, but a few (really quick and confusing) points:
    - Both the transmit and receive FIFO buffers on the TM4C are 16 bits - that's the max you can write or read on each SPI "command". That code I posted before as an example takes that in consideration, and because that sensor "word" is 32-bits, we do 2 sets of command. On the scope capture, you can see a short period without clock between each of the two sets.
    - No, there is no activity in MISO or MOSI outside the clocked area on those examples.
    - I can't answer about your specific sensor, but there are 4 SPI "modes". The difference between them is if they sample on the raising or falling clock transition, and if the CS is low or high. Try to discover which one your sensor uses (so far all we came across used the mode that the scope capture shows).
    - Check how long is each word of communication on your sensor, see if you are doing it properly on your program...
    This is the short piece of SPI configuration code that goes with the previously posted stuff:

    SSIClockSourceSet(hwSSIBase, SSI_CLOCK_SYSTEM); // SSI0_BASE - Redundant but professional
    SSIConfigSetExpClk(hwSSIBase,SYSTEM_CLOCK_HZ,SSI_FRF_MOTO_MODE_0,SSI_MODE_MASTER,7500000,16);
    SSIEnable(hwSSIBase);

    Regards
    Bruno
  • Bruno, 
    this is my SSI init function:
    
    
    void SSI0_init(){
    	
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    	
    	 
    	configureGPIOA(); // sets the port A pins 0 and 1 to non-alternate function
    	GPIOPinConfigure(GPIO_PA2_SSI0CLK);
    	GPIOPinConfigure(GPIO_PA3_SSI0FSS);
    	GPIOPinConfigure(GPIO_PA4_SSI0RX);
    	GPIOPinConfigure(GPIO_PA5_SSI0TX);
    	
    	
    	GPIOPinTypeSSI(GPIO_PORTA_BASE,GPIO_PIN_5|GPIO_PIN_4|GPIO_PIN_3|GPIO_PIN_2);
    	GPIOPinTypeGPIOInput(GPIO_PORTA_BASE, GPIO_PIN_1);	//DRDY
    	GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_0);	//CS
    	GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_6);	//PWDN
    	// CPOL = 0, CPHA = 1 --> SSI_FRF_MOTO_MODE_1
    	SSIConfigSetExpClk(SSI0_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_1, SSI_MODE_MASTER, 1000000, 8);
    	SSIEnable(SSI0_BASE);
    	
    }

    And i think that part is okay. In the datasheet it says the SPI mode is SSI_FRF_MOTO_MODE_1, and the CS is active when low. I've set SSI_FRF_MOTO_MODE_1 both in program and in Saleae options.
    The sensor sends 3 "words" in a row, each is 24 bits long, so I'm reading 8 bits 9 times and then later reassembling those to get proper data.

    Best regards,

    Laura

  • If you're still willing to review my code, there's been a few updates so I'm posting a new version here:
    project_v2.zip


    And here's a putty log of results:

    putty.log
    =~=~=~=~=~=~=~=~=~=~=~= PuTTY log 2017.06.21 17:24:08 =~=~=~=~=~=~=~=~=~=~=~=
    0 0 127 255 255 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 38 57 154 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 127 255 255 128 0 0 192 
    0 0 127 255 255 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 186 152 14 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 128 0 0 192 
    0 0 128 0 0 127 255 255 192 
    0 0 127 255 255 128 0 0 192 
    0 0 127 255 255 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 154 86 95 127 255 255 192 
    0 0 244 33 214 210 245 175 192 
    0 0 53 135 63 128 0 0 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 128 0 0 192 
    0 0 79 75 131 127 255 255 192 
    0 0 127 255 255 184 142 212 192 
    0 0 127 255 255 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 128 0 0 187 64 12 192 
    0 0 127 255 255 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 127 255 255 128 0 0 192 
    0 0 128 0 0 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 128 0 0 192 
    0 0 128 0 0 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 251 97 167 128 0 0 192 
    0 0 128 0 0 100 131 208 192 
    0 0 128 0 0 255 83 249 192 
    0 0 127 255 255 101 60 160 192 
    0 0 128 0 0 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 127 255 255 128 0 0 192 
    0 0 127 255 255 128 0 0 192 
    0 0 127 255 255 128 0 0 192 
    0 0 127 255 255 20 192 1 192 
    0 0 127 255 255 128 0 0 192 
    0 0 132 76 97 128 0 0 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 128 0 0 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 99 9 138 127 255 255 192 
    0 0 128 0 0 107 92 35 192 
    0 0 127 255 255 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 127 255 255 158 69 241 192 
    0 0 127 255 255 128 0 0 192 
    0 0 128 0 0 128 0 0 192 
    0 0 128 0 0 128 0 0 192 
    0 0 127 255 255 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 127 255 255 128 0 0 192 
    0 0 127 255 255 127 255 255 192 
    0 0 127 255 255 128 0 0 192 
    0 0 8 48 176 127 255 255 192 
    0 0 104 106 201 127 255 255 192 
    0 0 98 73 128 127 255 255 192 
    0 0 237 182 170 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 127 255 255 90 199 179 192 
    0 0 127 255 255 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 50 160 93 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 192 62 125 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 128 0 0 62 106 4 192 
    0 0 127 255 255 127 255 255 192 
    0 0 128 0 0 128 0 0 192 
    0 0 128 0 0 128 0 0 192 
    0 0 127 255 255 128 0 0 192 
    0 0 127 255 255 135 86 187 192 
    0 0 127 255 255 117 66 204 192 
    0 0 128 0 0 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 127 255 255 133 79 153 192 
    0 0 128 0 0 177 208 174 192 
    0 0 128 0 0 128 0 0 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 195 127 207 128 0 0 192 
    0 0 127 255 255 128 0 0 192 
    0 0 128 0 0 128 0 0 192 
    0 0 127 255 255 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 128 0 0 192 
    0 0 128 0 0 155 104 27 192 
    0 0 169 211 162 128 0 0 192 
    0 0 128 0 0 127 255 255 192 
    0 0 217 194 34 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 207 106 193 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 128 0 0 128 0 0 192 
    0 0 128 0 0 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 153 125 161 127 255 255 192 
    0 0 127 255 255 127 150 42 192 
    0 0 127 255 255 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 127 255 255 128 0 0 192 
    0 0 128 0 0 128 0 0 192 
    0 0 127 255 255 128 0 0 192 
    0 0 128 0 0 128 0 0 192 
    0 0 127 255 255 128 0 0 192 
    0 0 128 0 0 127 255 255 192 
    0 0 55 128 169 254 125 192 192 
    0 0 201 215 85 127 255 255 192 
    0 0 35 187 142 22 45 27 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 242 136 23 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 128 0 0 192 
    0 0 128 0 0 128 0 0 192 
    0 0 0 127 33 128 0 0 192 
    0 0 177 76 74 128 0 0 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 128 0 0 192 
    0 0 128 0 0 128 0 0 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 128 0 0 192 
    0 0 128 0 0 128 0 0 192 
    0 0 128 0 0 128 0 0 192 
    0 0 127 255 255 127 255 255 192 
    0 0 128 0 0 104 219 45 192 
    0 0 130 138 184 127 255 255 192 
    0 0 127 255 255 128 0 0 192 
    0 0 226 41 135 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 127 255 255 128 0 0 192 
    0 0 127 255 255 128 0 0 192 
    0 0 128 0 0 79 166 32 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 21 173 220 127 255 255 192 
    0 0 255 171 66 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 28 34 12 128 0 0 192 
    0 0 128 0 0 128 0 0 192 
    0 0 127 255 255 127 255 255 192 
    0 0 128 0 0 128 0 0 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 201 44 249 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 105 121 72 127 255 255 192 
    0 0 128 0 0 128 0 0 192 
    0 0 127 255 255 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 127 133 97 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 251 211 167 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 128 0 0 80 207 246 192 
    0 0 128 0 0 127 255 255 192 
    0 0 127 255 255 128 0 0 192 
    0 0 128 0 0 128 0 0 192 
    0 0 127 255 255 128 0 0 192 
    0 0 127 255 255 128 0 0 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 78 77 26 127 255 255 192 
    0 0 127 255 255 128 0 0 192 
    0 0 128 0 0 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 121 84 137 128 0 0 192 
    0 0 128 0 0 201 39 164 192 
    0 0 128 0 0 128 0 0 192 
    0 0 128 0 0 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 128 0 0 192 
    0 0 127 255 255 127 255 255 192 
    0 0 128 0 0 128 0 0 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 245 62 123 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 128 0 0 121 214 231 192 
    0 0 114 221 23 127 255 255 192 
    0 0 127 255 255 128 0 0 192 
    0 0 127 255 255 127 255 255 192 
    0 0 127 255 255 128 0 0 192 
    0 0 127 255 255 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 128 0 0 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 128 0 0 192 
    0 0 127 255 255 127 255 255 192 
    0 0 84 65 230 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 160 194 223 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 224 172 88 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 95 92 95 128 0 0 192 
    0 0 127 255 255 176 202 244 192 
    0 0 220 185 234 127 255 255 192 
    0 0 127 255 255 128 0 0 192 
    0 0 127 255 255 127 255 255 192 
    0 0 128 0 0 128 0 0 192 
    0 0 127 255 255 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 169 139 87 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 128 0 0 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    0 0 127 255 255 127 255 255 192 
    



    In the folder I put some screenshots of the Saleae files (but the MISO line is irrelevant since it's measured on the TiVa LaunchPad and not on the real board).
    Thanks in advance :)

    Best regards, 

    Laura

  • Laura,

    Took a quick look at it.

    Just so you know, you can still use PA3 to connect to the CS - we just recommend it to be configured as GPIO instead of letting the SSI hardware take care. That would be more practical in case you later actually want to try to use the CS pin automatically controlled.

    The saleae signals now look reasonable. The mode for the sensor is really MODE_1, BUT your file main2.c parameter is MODE_0.

    The frequency is correct at 1MHz (just double check, measure the frequency on the analyzer, for the SSI dividers sometime generate faster values than what is passed on the Tivaware parameter.

    Do the values you see on saleae MOSI match what you are actually sending on the Tiva?

    The writing/reading sequence on your while loop is confused... You are not reading everything.

    Look and compare the code I posted on an earlier message: you are using your SSI as 8 bits, so everytime you place 8 bits out, there will be 8 bits on the receive buffer which you must read (and later reconstruct). And instead of a blind wait loop, just check until the SPI bits are all sent, then read what came back.

    Cheers

    Bruno

  • Bruno,

    The FSS pin is not physically connected to anything on the board and the GPIO_PORTA_PIN0 is physically connected to the CS, as shown in the scheme:


    That's why I don't use the FSS, but thanks for the tip.

    About the file main2.c, it's some prahistoric version from a time I had no idea what I'm doing. Sorry for the confusion, I forgot to delete it from the project file and it's not included in the Keil project so it didn't cross my mind. The real important files are main.cpp and ads1292r.cpp, and the SSI_MODE_1 is defined in the main.cpp.

    The values I'm seeing on the MOSI line match what I'm trying to send.


    Bruno Saraiva said:
    everytime you place 8 bits out, there will be 8 bits on the receive buffer which you must read

    This is the piece of information that I've been missing. I thought that's just some programming practice, reading useless data even though your goal is just to send it, not a must. I will fix that now.
    Thanks a lot for your time! Hope it will work now, I'll get back to you either way.

    Cheers!

    Laura :)