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.

CCS/TM4C123GH6PM: SSIDATAGET() FUNCTION ERROR

Part Number: TM4C123GH6PM


Tool/software: Code Composer Studio

Hello ,

I write this conditional ssi algorithm for my projects but there is an error while i am debugging. I debug this code step by step and ssidataget() function ( in data_receive() ) is error. What can i for stop this ??

#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_can.h"
#include "inc/hw_ints.h"
#include "inc/hw_gpio.h"
#include "driverlib/debug.h"
#include "driverlib/sysctl.h"
#include "driverlib/systick.h"
#include "driverlib/gpio.h"
#include "driverlib/uart.h"
#include "driverlib/interrupt.h"
#include "driverlib/pin_map.h"
#include "driverlib/pwm.h"
#include "driverlib/rom.h"
#include "driverlib/i2c.h"
#include "driverlib/rom_map.h"
#include "driverlib/watchdog.h"
#include "driverlib/adc.h"
#include "driverlib/can.h"
#include "driverlib/eeprom.h"
#include "driverlib/timer.h"
#include "driverlib/ssi.h"

bool isAdcReadOk;

#define NUM_SSI_DATA 3
uint32_t ui32ADC0Value[3];
uint32_t ui32Index;
uint32_t ulindex;;
uint32_t Data_Alinan[3];

#define PIN_LOW 0x00
#define PIN_HIGH 0xFF

void adckesme(void)
{
ADCIntClear(ADC0_BASE, 3);
ADCSequenceDataGet(ADC0_BASE , 3, ui32ADC0Value);
}

void SSI_DATA_BAS(uint32_t SSI_NUMBER,uint32_t *DATA)
{
for(ui32Index = 0; ui32Index < NUM_SSI_DATA; ui32Index++)
{
SSIDataPut(SSI_NUMBER, *DATA); //// requesting data
}
}

void data_receive(void)
{
// GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_3, PIN_LOW);
for(ui32Index=0 ; ui32Index < 3 ; ui32Index++){
SSIDataGet(SSI0_BASE, &Data_Alinan[0]);
}
Data_Alinan[0] &= 0x00FF;
Data_Alinan[1] &= 0x00FF;
Data_Alinan[2] &= 0x00FF;

while(SSIBusy(SSI0_BASE)){};
// GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_3, PIN_HIGH);

}

void InitConsole_SPI(void)
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
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);
SSIConfigSetExpClk(SSI0_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_0,SSI_MODE_SLAVE, 2000000, 8);
SSIEnable(SSI0_BASE);

}

int main(void)
{
SysCtlClockSet(SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ|SYSCTL_SYSDIV_5);

SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);

ADCHardwareOversampleConfigure(ADC0_BASE,64);

ADCSequenceDisable(ADC0_BASE, 3);
ADCSequenceConfigure(ADC0_BASE , 3, ADC_TRIGGER_PROCESSOR, 0);
ADCSequenceStepConfigure(ADC0_BASE, 3, 0 , ADC_CTL_TS|ADC_CTL_IE|ADC_CTL_END);
ADCSequenceEnable(ADC0_BASE, 3);

ADCIntEnable(ADC0_BASE, 3);
ADCIntRegister(ADC0_BASE, 3, adckesme);

IntEnable(INT_ADC0SS3);

InitConsole_SPI();

while(1)
{
ADCProcessorTrigger(ADC0_BASE , 3);
// while(SSIBusy(SSI0_BASE)){};
data_receive();
// while(SSIBusy(SSI0_BASE)){};

if(Data_Alinan[0]==1){ ///// Did the data request come ?

if(ui32ADC0Value[0] != 0 ){ //// Is there data in adc ?

SSI_DATA_BAS(SSI0_BASE , ui32ADC0Value);

}

}

}
}

  • Hi,

      Did you have a chance to reference the TivaWare ADC and SSI examples?

      Please be more specific about what error you are getting?

      You cannot unconditionally keep on calling the data_receive() in your while(1) loop. You need to wait until there is data in the RXFIFO before you call the SSIDataGet. To wait for data in the FIFO you can try polling for RNE (FIFO not empty) or poll for RXRIS (the RXFIFO is half full or more). 

      You need to also use a scope or logic analyzer to make sure your master is sending the correct data.

      I'm not sure why you want base on the SSI received data to send your ADC conversion data out. If your external device can just toggle a GPIO input pin to notify the MCU to start sampling and then send out the converted data then it would be easier to synchronize everything. It is your application, you need to figure out what is the best method for your systems. 

  • Hi Charles,

    Charles Tsai said:
    If your external device can just toggle its GPIO Output pin - the MCU's (connected) GPIO input pin notifies the MCU to start sampling - and then send out the converted data then it would be easier to synchronize everything.

    EXCELLENT ADVICE!    Posters must learn to "Employ KISS" - most always there exists a, "Simpler & Better Method!"