cancel
Showing results for 
Search instead for 
Did you mean: 

[STM32U545] OSPI write only

Loïc1
Associate II

Hello,

I'm working on a projet where I need to drive 4 (or 2 x 4) GPIO at the same time with high speed on the STM32U545RE.

I'm trying to use the DualQuad SPI (with OSPI) but I can't have the clock working...

At first I tried to write a code with a send only type of frame (with no instruction and no address) but nothing was working.

Now I tried to use the example code from a STM32L5 but nothing seem to be working either.

 

Can you if someone already tried to do that ?

 

BR,

Loïc

10 REPLIES 10
Loïc1
Associate II

Hello @KDJEM.1 ,

 

I understand what you say, but with several try I've manage to do a send only data with OSPI :

tek00001.png

This is the clock.

Here is the code :

int main(void)
{
     OSPI_RegularCmdTypeDef sCommand;

     /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
     HAL_Init();

     /* Configure the System Power */
     SystemPower_Config();

     /* Configure the system clock */
     SystemClock_Config();

     /* Initialize all configured peripherals */
     MX_GPIO_Init();
     MX_DMA_Init();
     MX_ICACHE_Init();
     MX_OCTOSPI1_Init();

     sCommand.OperationType         = HAL_OSPI_OPTYPE_COMMON_CFG;
     sCommand.FlashId               = HAL_OSPI_FLASH_ID_1;
     sCommand.Instruction           = INIT_FRAME_COM_PHASE;
     sCommand.InstructionMode       = HAL_OSPI_INSTRUCTION_NONE;
     sCommand.InstructionSize       = HAL_OSPI_INSTRUCTION_8_BITS;
     sCommand.InstructionDtrMode    = HAL_OSPI_INSTRUCTION_DTR_DISABLE;
     sCommand.Address               = 0;
     sCommand.AddressMode           = HAL_OSPI_ADDRESS_NONE;
     sCommand.AddressSize           = HAL_OSPI_ADDRESS_24_BITS;
     sCommand.AddressDtrMode        = HAL_OSPI_ADDRESS_DTR_DISABLE;
     sCommand.AlternateBytes        = 0;
     sCommand.AlternateBytesMode    = HAL_OSPI_ALTERNATE_BYTES_NONE;
     sCommand.AlternateBytesSize    = HAL_OSPI_ALTERNATE_BYTES_8_BITS;
     sCommand.AlternateBytesDtrMode = HAL_OSPI_ALTERNATE_BYTES_DTR_DISABLE;
     sCommand.DataMode              = HAL_OSPI_DATA_4_LINES;
     sCommand.DataDtrMode           = HAL_OSPI_DATA_DTR_DISABLE;
     sCommand.DummyCycles           = 0;
     sCommand.DQSMode               = HAL_OSPI_DQS_DISABLE;
     sCommand.SIOOMode              = HAL_OSPI_SIOO_INST_EVERY_CMD;

   while(1)
   {
      sCommand.NbData         = LENGTH_32BIT;

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

      if (HAL_OSPI_Transmit_DMA(&hospi1, &data_to_send) != HAL_OK)
      {
    	  HAL_OSPI_GetError(&hospi1);
    	  Error_Handler();
      }
   }
}

 

But I have a problem, there is to many time between 2 send (between 2 loop) :

tek00002.png

 

The system clock is at 160MHz, I don't know why it takes that long to loop. Any ideas ?

 

Best Regards,

Loïc