0
\$\begingroup\$

I am trying to communicate with external flash via quadspi but this time with cubemx and hal libraries. Everything seems to be working fine unless I write something bigger than 0x03 to address register. When I write address 0x04 or bigger, program just stuck. I debugged and after this line

if(((HAL_GetTick() - Tickstart) > Timeout) || (Timeout == 0U))
  {
    hqspi->State     = HAL_QSPI_STATE_ERROR;        // it doesnt get in 
    hqspi->ErrorCode |= HAL_QSPI_ERROR_TIMEOUT;     // this function. 
                                                    // loops without entering
    return HAL_ERROR;
  }

it goes to

__weak uint32_t HAL_GetTick(void)
{
   return uwTick;
}

and loops back .

This is the part of my code where this error occurs

static void quadspi_getFeature(void){
    getFeature.InstructionMode              =   QSPI_INSTRUCTION_1_LINE;
    getFeature.Instruction                  =   GET_FEATURE;
    getFeature.AddressMode                  =   QSPI_ADDRESS_1_LINE;
    getFeature.AddressSize                  =   QSPI_ADDRESS_8_BITS;
    getFeature.AlternateByteMode            =   QSPI_ALTERNATE_BYTES_NONE;
    getFeature.DataMode                     =   QSPI_DATA_NONE;
    getFeature.DummyCycles                  =   16;
    getFeature.Address                      =   STATUS_ADDRESS;
    getFeature.DdrMode                      =   QSPI_DDR_MODE_DISABLE;
    getFeature.SIOOMode                     =   QSPI_SIOO_INST_EVERY_CMD;
    getFeature.NbData                       =   0;
    HAL_QSPI_Command(&hqspi, &getFeature, 1000);
}

I tried changing the value of TimeOut in HAL_QSPI_Transmit command but nothing changed.

\$\endgroup\$
4
  • \$\begingroup\$ I do not fully understand... When the timeout function in never entered, how do you know you have a timeout error? \$\endgroup\$
    – jusaca
    Commented Feb 8, 2020 at 12:32
  • \$\begingroup\$ That code is just out of context. Typically there would be a loop that waits for transmission completion, and that would be the part to check the timeout. \$\endgroup\$
    – Justme
    Commented Feb 8, 2020 at 13:07
  • \$\begingroup\$ I dont understand fully either, I am not familiar with hal libraries, but it returns that function constantly. So, I tought may be the timeout causes the problem. @Justme So, the problem is it doesn't finish the transmission therefore code stuck in loop? \$\endgroup\$ Commented Feb 8, 2020 at 13:16
  • 1
    \$\begingroup\$ Yes, it runs that piece of code constantly, because timeout has not happened yet. It reads the HAL milliseconds count, and if more than the 1000 you have given in the parameter exceeds, then it will set the state to error, timeout flag to errorcode, and returns away from current function with HAL_ERROR as return value. Otherwise, it will wait for something else to happen, like transaction complete. \$\endgroup\$
    – Justme
    Commented Feb 8, 2020 at 14:36

1 Answer 1

0
\$\begingroup\$

I found it, flash size set incorrectly. I was sure that I set it right, so either cubemx or I made a mistake. After correcting it, problem solved.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.