cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7 Delay Block Configuration (LNGF does not get set)

JRS
Associate III

Hi,

I was trying to configure the Delay Block on the STM32H723xx for the Octo-SPI (in my case OCTOSPI2). The datasheet documentation on that part is quite simple with 6 steps, but I get stuck at the Line Length Valid Flag. After the first round (unit = 0) is ok, at the second unit (unit = 1) it gets stuck while waiting for the LNGF Flag which never comes.

Input Clock of the OSPI2 Module is 100 MHz (tried it with PLL or HCLK3). Hardware Registers of the OSPI2 in Debugger look fine: DLYB_CR-SEN|DEN, DLYB_CFGR-SEL=12, LNGF for first round =1, UNIT =1 for second round, but LNGF never gets set. Clock is activated, since I enabled the Memory Mapped mode for the peripheral prior to this.

The function I used (based on stm32h7xx_ll_delayblock, which gives also a timeout):

HAL_StatusTypeDef DelayBlock_Enable(DLYB_TypeDef *DLYBx)
{
	uint32_t line = 10;
	DLYBx->CR = DLYB_CR_DEN | DLYB_CR_SEN;	//DEN ->Enable, SEN- SamplerEnable -> Disable Clock Output for Entering Units
		/* lng_mask is the mask bit for the LNG field to check the output of the UNITx*/
		for (uint32_t unit_current = 0U; unit_current < DLYB_MAX_UNIT; unit_current++)
		{
			/* Set the Delay of the UNIT(s) and Select Bits to 12*/
			DLYBx->CFGR = DLYB_MAX_SELECT | (unit_current << DLYB_CFGR_UNIT_Pos);
			/* Waiting for a LNG valid value */
			const uint32_t tickstart = HAL_GetTick();
			while ((DLYBx->CFGR & DLYB_CFGR_LNGF) == 0U)  //<--at unit = 1 it gets stuck
			{
				if ((HAL_GetTick() - tickstart) >=  DLYB_TIMEOUT)  
				{
					DLYBx->CR   = DLYB_CR_DEN;
					return HAL_TIMEOUT;
				}
			}
			volatile uint32_t lngmask = DLYBx->CFGR&DLYB_CFGR_LNG_Msk;
			if (lngmask>0)
			{
				if (((lngmask&DLYB_CFGR_LNG_10)==0)
					||((lngmask&DLYB_CFGR_LNG_11)==0))
				{
					while (line>0)
					{
						if (lngmask&(1 << (DLYB_CFGR_LNG_Pos + line)))
						{
							break;
						}
						--line;
					}
					break;
				}
			}	
		}
	/* Apply the Tuning settings */
	DLYBx->CR   = 0U;
	DLYBx->CR   = DLYB_CR_DEN | DLYB_CR_SEN;
	DLYBx->CFGR = (line << DLYB_CFGR_UNIT_Pos);
	DLYBx->CR   = DLYB_CR_DEN;
	return HAL_OK;
}

10 REPLIES 10

Ok thanks.

I will try to adapt those functions and I'll let you know how it will go...

Those are definitively different from what is generated here so it's worth a try...I will adapt them and try...

Thanks again