cancel
Showing results for 
Search instead for 
Did you mean: 

stm32u545 OCTPSPI can't output wave in io pins

LoganLi
Associate II

hello, I ues OCTOSPI device in STM32U545, it just generate cs and clock wave when run this code.

HAL_OSPI_Command(hospi, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE)
But io 0-3 nothing happened.
I have reference the examples, it's use OCTOSPIM what not in STM32U545.
6 REPLIES 6
FBL
ST Employee

Hello @LoganLi 

Do you interface NOR or PSRAM? HAL_OSPI_Command() function sends a command to the target memory, but you need to specify the correct command code, address and data. Then, you can use HAL_OSPI_Transmit() and HAL_OSPI_Receive() functions to send and receive data to and from the memory. 

For STM32U535/545 devices, you can refer to the datasheet and corresponding configuration based on the specifications in reference manual to customize the examples. 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Show the command structure and more of the code so there's some chance of understanding what's wrong or going on.

Assume the audience isn't psychic.

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

Check if there are any interrupt-related issues. If there are callback functions associated with the OCTOSPI peripheral, make sure they are implemented correctly and provide the necessary functionality.

Thank you!

It's NOR flash, and I have spectify the correct command code.The code is here:

void ospi1_init(void)
{
    hospi1.Instance = OCTOSPI1;
    hospi1.Init.FifoThreshold = 4;
    hospi1.Init.DualQuad = HAL_OSPI_DUALQUAD_DISABLE;
    hospi1.Init.MemoryType = HAL_OSPI_MEMTYPE_MICRON;
    hospi1.Init.DeviceSize = 24;
    hospi1.Init.ChipSelectHighTime = 4;
    hospi1.Init.FreeRunningClock = HAL_OSPI_FREERUNCLK_DISABLE;
    hospi1.Init.ClockMode = HAL_OSPI_CLOCK_MODE_0;
    hospi1.Init.WrapSize = HAL_OSPI_WRAP_NOT_SUPPORTED;
    hospi1.Init.ClockPrescaler = 96;
    hospi1.Init.SampleShifting = HAL_OSPI_SAMPLE_SHIFTING_HALFCYCLE; // HAL_OSPI_SAMPLE_SHIFTING_NONE; //
                                                                     // HAL_OSPI_SAMPLE_SHIFTING_HALFCYCLE;
    hospi1.Init.ChipSelectBoundary = 0;
    hospi1.Init.MaxTran = 0;
    hospi1.Init.Refresh = 0;

    hospi1.Init.DelayHoldQuarterCycle = HAL_OSPI_DHQC_ENABLE;
    hospi1.Init.DelayBlockBypass = HAL_OSPI_DELAY_BLOCK_USED;


    if (HAL_OSPI_Init(&hospi1) != HAL_OK) {
        Error_Handler();
    }
    OSPI_OctalModeCfg(&hospi1);
}

void OSPI_OctalModeCfg(OSPI_HandleTypeDef *hospi)
{
    OSPI_RegularCmdTypeDef sCommand;
    OSPI_AutoPollingTypeDef sConfig;
    uint8_t reg;

    /* Enable write operations ---------------------------------------- */
    sCommand.OperationType = HAL_OSPI_OPTYPE_COMMON_CFG;
    sCommand.FlashId = HAL_OSPI_FLASH_ID_1;
    sCommand.Instruction = WRITE_ENABLE_CMD;
    sCommand.InstructionMode = HAL_OSPI_INSTRUCTION_1_LINE;
    sCommand.InstructionSize = HAL_OSPI_INSTRUCTION_8_BITS;
    sCommand.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_DISABLE;
    sCommand.AddressMode = HAL_OSPI_ADDRESS_NONE;
    sCommand.AlternateBytesMode = HAL_OSPI_ALTERNATE_BYTES_NONE;
    sCommand.DataMode = HAL_OSPI_DATA_NONE;
    sCommand.DummyCycles = 0;
    sCommand.DQSMode = HAL_OSPI_DQS_DISABLE;
    sCommand.SIOOMode = HAL_OSPI_SIOO_INST_EVERY_CMD;

    if (HAL_OSPI_Command(hospi, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) {
        Error_Handler();
    }

    /* Configure automatic polling mode to wait for write enabling ---- */
    sCommand.Instruction = READ_STATUS_REG_CMD;
    sCommand.DataMode = HAL_OSPI_DATA_1_LINE;
    sCommand.DataDtrMode = HAL_OSPI_DATA_DTR_DISABLE;
    sCommand.NbData = 1;

    if (HAL_OSPI_Command(hospi, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) {
        Error_Handler();
    }

    sConfig.Match = WRITE_ENABLE_MATCH_VALUE;
    sConfig.Mask = WRITE_ENABLE_MASK_VALUE;
    sConfig.MatchMode = HAL_OSPI_MATCH_MODE_AND;
    sConfig.Interval = AUTO_POLLING_INTERVAL;
    sConfig.AutomaticStop = HAL_OSPI_AUTOMATIC_STOP_ENABLE;

    if (HAL_OSPI_AutoPolling(hospi, &sConfig, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) {
        Error_Handler();
    }
// ... ...
}

As described previously, nothing happen in io0-3

 

I want use it as normal SPI interface firstly but also failed.

 

Thanks

It just run in polling mode.

I have post it, thank you very much.