cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H757: Trying to read ID (Command 0x9F) HAL_QSPI_Receive locks up.

ATrow.1
Associate

I'm starting super simple - Just reading the Manufacturer ID. Using a Cypress S25FL256L Flash. My test program:

--------

void QSPI_TestTask (void * pvParameters)

{

  QSPI_CommandTypeDef sCommand;

  uint32_t      MyID = 0;

  /* Initialize QuadSPI ------------------------------------------------------ */

  hqspi.Instance = QUADSPI;

  HAL_QSPI_DeInit (&hqspi);

  hqspi.Init.ClockPrescaler   = 1;

  hqspi.Init.FifoThreshold   = 4;

  hqspi.Init.SampleShifting   = QSPI_SAMPLE_SHIFTING_NONE;

  hqspi.Init.FlashSize     = QSPI_FLASH_SIZE;

  hqspi.Init.ChipSelectHighTime = QSPI_CS_HIGH_TIME_1_CYCLE;

  hqspi.Init.ClockMode     = QSPI_CLOCK_MODE_0;

  hqspi.Init.FlashID      = QSPI_FLASH_ID_1;

  hqspi.Init.DualFlash     = QSPI_DUALFLASH_DISABLE;

  if (HAL_QSPI_Init (&hqspi) != HAL_OK)

  {

    printf ("HAL_QSPI_Init ERROR\n");

    Error_Handler ();

  }

  MyID = QSPI_S25FL256L_ReadID ();

  printf ("QSPI_S25FL256L_ReadID Returned %ld\n", MyID);

}

uint32_t QSPI_S25FL256L_ReadID (void)

{

  // Cypress S25FL256L

  QSPI_CommandTypeDef s_command;       // QSPI transmission configuration

  uint8_t       QSPI_ReceiveBuff [3];  // Store the data read by QSPI

  uint32_t      S25FL_ID;        // Device ID

  s_command.InstructionMode  = QSPI_INSTRUCTION_1_LINE;   // 1 line instruction mode

  s_command.AddressSize    = QSPI_ADDRESS_24_BITS;     // 24 bit address

  s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE;  // No delivery byte

  s_command.DdrMode      = QSPI_DDR_MODE_DISABLE;    // Prohibit DDR mode

  s_command.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY;  // DDR mode data delay, not used here

  s_command.SIOOMode     = QSPI_SIOO_INST_EVERY_CMD;   // Send instructions each time transfer

  s_command.AddressMode    = QSPI_ADDRESS_NONE;      // No address mode

  s_command.DataMode     = QSPI_DATA_1_LINE;       // 1 line data mode

  s_command.DummyCycles    = 0;              // empty cycle

  s_command.NbData      = 3;              // Transport data length

  s_command.Instruction    = READ_ID_CMD2;         // Perform a read device ID command

  // Send instructions

  printf ("QSPI_S25FL256L_ReadID: Calling HAL_QSPI_Command\n");

  if (HAL_QSPI_Command (&hqspi, &s_command, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)

  {

    printf ("QSPI_S25FL256L_ReadID: HAL_QSPI_Command READ_ID_CMD2 ERROR\n");

    return (-1);

  }

  // Receive data

  printf ("QSPI_S25FL256L_ReadID: Calling HAL_QSPI_Receive\n");

  if (HAL_QSPI_Receive (&hqspi, QSPI_ReceiveBuff, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)

  {

    printf ("QSPI_S25FL256L_ReadID: HAL_QSPI_Receive READ_ID_CMD2 ERROR\n");

    return (-1);

  }

  // Combined with the obtained data into ID

  printf ("QSPI_S25FL256L_ReadID: GOT ID!\n");

  S25FL_ID = ((QSPI_ReceiveBuff [0] << 16) | (QSPI_ReceiveBuff [1] << 8 ) | QSPI_ReceiveBuff [2]);

  return S25FL_ID;  // Return ID

} // QSPI_S25FL256L_ReadID

-------------------------------

RESULTS:

QSPI_S25FL256L_ReadID: Calling HAL_QSPI_Command

QSPI_S25FL256L_ReadID: Calling HAL_QSPI_Receive

<< Board lock up, WDOG resets MCU >>

Any clue why?

1 REPLY 1

Clear the structures on the stack, turn off the watchdog so you can actually debug the situation and check the QSPI status.

Clocking looks a bit aggressive, would back that off until you have it working.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..