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.

TM4C1294NCPDT: SPI Flash access issue in bootloader when power supply is connected

Part Number: TM4C1294NCPDT

Hi,

I am having an issue with spi read status register at the bootloader. The issue seems to be only when power supply is connected, however the same piece of code works when debugger (MikroeProg) is connected.

I seems a bit strange why it fails. The failure seems to be when it does read status register.

SysCtlPeripheralEnable( SYSCTL_PERIPH_GPIOQ);
SysCtlPeripheralEnable( SYSCTL_PERIPH_GPION);
GPIOPinTypeGPIOOutput(GPIO_PORTQ_BASE, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_4);
GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_4);
GPIOPinTypeGPIOInput(GPIO_PORTQ_BASE, GPIO_PIN_3);
spi_deselect();
  SysCtlPeripheralReset(SYSCTL_PERIPH_SSI3);
SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI3);
GPIOPinConfigure(GPIO_PQ0_SSI3CLK);
GPIOPinConfigure(GPIO_PQ3_SSI3XDAT1);
GPIOPinConfigure(GPIO_PQ2_SSI3XDAT0);
GPIOPinWrite(GPIO_PORTQ_BASE, GPIO_PIN_4 , GPIO_PIN_4); // Disable WP
GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_5 , GPIO_PIN_5); // Disable hold
GPIOPinTypeSSI(GPIO_PORTQ_BASE, GPIO_PIN_0|GPIO_PIN_2 | GPIO_PIN_3);
uint32_t g_ui32SysClock;
g_ui32SysClock	=SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480),50000000 );
  SSIConfigSetExpClk(SSI3_BASE, g_ui32SysClock,
                         SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, SST25_FLASH_SPI_RATE, 8);

SSIEnable(SSI3_BASE);
  {
      unsigned long Temp;
      while(SSIDataGetNonBlocking(SSI3_BASE, Temp))
      {
      }
  }

        spi_write(SST25_CMD_RDSR);
	uint8_t spi_val = spi_write(0); // dummy
	spi_deselect();
//	while (spi_val != 0x02) ; // Error! Failure at this line.

For the time being i have commented out the check for 0x02.

I went through the data sheet to see if i have missed out any initialization, but could not find anything. If anyone has clues why this fails at bootloader when power supply is connected and same code works when jtag/debugger is used.

Any suggestions / workaround will be great.

Thank you

Kumar

  • In the past I have seen this behavior (works with debugger, does not work from power on) when an initialization step is out of sequence. I am not familiar with the MikroeProg debugger, but often when debugging, your code has run once when the device powers on and then the debugger sets the PC back to the start of the code and it runs again without doing a system reset. The second time through the initialization works. For example, if you configure a peripheral before enabling it, the first time through the configuration is ignored, the second time through the configuration works because the peripheral was enabled by the first pass.

    One way to check this is to have the debugger do a system reset before running the code. This puts all of the peripherals back into their power-on reset state and emulates starting from power on.

    Another thought is to look at the SPI output with a digital scope and comparing the output from a power-on to the output when running with the debugger.