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.

LM4F120H5QR code stops at GPIOPinConfigure(GPIO_PCTL_PD2_SSI1RX);

Other Parts Discussed in Thread: ADS1271

Hi,

I've a problem with SSI and stellarisware on the TI Stellaris Launchpad.

While the configuration of the SSI1 peripherial (same way as in stellarisware example), the programm seems to stop at "GPIOPinConfigure(GPIO_PCTL_PD2_SSI1RX);".
I don't know why and any other things are working well...

Code:

void SerialInit(unsigned int baud) {
	SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
	GPIOPinConfigure(GPIO_PA0_U0RX);
	GPIOPinConfigure(GPIO_PA1_U0TX);
	GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
	UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), baud,
			(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));
}

void SerialSyncPrintChar(char c) {
    UARTCharPut(UART0_BASE, c);
}
void SerialSyncPrintE(char* msg) { unsigned int cCount = strlen(msg); int i = 0; for (i = 0; i < cCount; i++) { SerialSyncPrintChar(msg[i]); } } void init_SpiADC() { SerialSyncPrintE("SSI1"); SerialSyncPrintE("i0"); SysCtlDelay(2666666); SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI1); SerialSyncPrintE("i1"); SysCtlDelay(2666666); GPIOPinConfigure(GPIO_PCTL_PD0_SSI1CLK); GPIOPinConfigure(GPIO_PCTL_PD1_SSI1FSS); SerialSyncPrintE("i2"); SysCtlDelay(2666666); GPIOPinConfigure(GPIO_PCTL_PD2_SSI1RX); SerialSyncPrintE("i3"); SysCtlDelay(2666666); GPIOPinConfigure(GPIO_PCTL_PD3_SSI1TX); SerialSyncPrintE("i4"); SysCtlDelay(2666666); GPIOPinTypeSSI(GPIO_PORTD_BASE, (GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3)); SerialSyncPrintE("i5"); SysCtlDelay(2666666); SSIConfigSetExpClk(SSI1_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, SysCtlClockGet() / 64, 8); // -> 80Mhz/64 -> 0.625Mhz SPI Clock SerialSyncPrintE("i6"); SysCtlDelay(2666666); // Enable the SSI0 module. SSIEnable(SSI1_BASE); // ... } int main(void) { SysCtlClockSet( SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); SysCtlPeripheralEnable( SYSCTL_PERIPH_GPIOA | SYSCTL_PERIPH_GPIOB | SYSCTL_PERIPH_GPIOD | SYSCTL_PERIPH_GPIOE | SYSCTL_PERIPH_GPIOF); SerialInit(115200); // 115200 Baud SysCtlDelay(2666666); // ADC over SPI: init_SpiADC(); // ... }

I see receive "i2", but never "i3" :(

If anyone could provide any information on this I'd be very greatful!

regards

Raphael.

  • Hello Raphael

    The GPIOPinConfigure function call expects the parameters from the pin_map.h. The above code should be

    	GPIOPinConfigure(GPIO_PD0_SSI1CLK);
    	GPIOPinConfigure(GPIO_PD1_SSI1FSS);
    	SerialSyncPrintE("i2");
    	SysCtlDelay(2666666);
    	GPIOPinConfigure(GPIO_PD2_SSI1RX);
    	SerialSyncPrintE("i3");
    	SysCtlDelay(2666666);
    	GPIOPinConfigure(GPIO_PD3_SSI1TX);	

    Regards

    Amit

  • Hello,

    your solution works, thank your very much.

    Now i have an other Problem:

    the following code should return the value of the ADC ADS1271 (http://www.ti.com/lit/ds/symlink/ads1271.pdf), but i always get 0 (from spi_data and ret).

    The ADS1271 is running in High Speed Mode and Format ist set to SPI (both FORMAT and MODE pins direct connected to ground; the DIN pin ist also connected to ground; PWDN pin is switches by teh Stellaris MCU to 0 and the clock input (CLK) is direct connected to an XO22 27MHz oscillator).

    long readSpiADC2() {
    	unsigned long spi_data = 0L;
    	unsigned long ret = 0L;
    	char byten[3];
    	unsigned long dummy_data = 0xFFFFFFFF;
    
    	// wait until DRDY (connected to PD_7) gets low
    	while (adcDRDY()) {
    		serialTrick();
    	}
    	SysCtlDelay(100);
    	// Receive 3 bytes of data.
    	for (int h = 0; h <= 2; h++) {
    		SSIDataPutNonBlocking(SSI1_BASE, dummy_data);
    	}
    	for (int i = 0; i <= 2; i++) {
    		SSIDataGet(SSI1_BASE, &spi_data);
    		byten[i] = spi_data;
    		spi_data = 0L;
    		SerialSyncPrintE("#i spi_data: ");
    		SerialSyncPrintI(spi_data);
    		SerialSyncPrintE("\r\n");
    	}
    	// Not necessary:
    	while (SSIBusy(SSI1_BASE)) {
    	}
    	ret = ((byten[0] << 16) | (byten[1] << 8) | (byten[2]));
    	SerialSyncPrintE("#i ret: ");
    	SerialSyncPrintI(ret);
    	SerialSyncPrintE("\r\n");
    	return ret;
    }
    
    int adcDRDY() {
    	if (GPIOPinRead(GPIO_PORTD_BASE, GPIO_PIN_7) == GPIO_PIN_7)
    		return 1;
    	else
    		return 0;
    }


    I do not have an logic analyser or an oscilloscope, so i can not see whether the adc sends out something over spi.

    Is the code correct and the ADS1271 defect?

    Thanks.

  • Hello Raphael,

    First of all, can you hare the configuration code for SSI on the Tiva device side. We need to make sure that it is correct. Also I do not understand what the function serialTick() is protoyped as.

    Lastly, connecting a scope/LA would be better than debugging the code since we need to make sure the CS and CLK pulses are going as expected to the external device.

    Regards

    Amit