cancel
Showing results for 
Search instead for 
Did you mean: 

Stm32f415 and Frame Timinig Jitter on USB HOST problem

Marco1
Associate II
Posted on August 09, 2016 at 13:05

HI, 

i have configured my stm32f415rgt with CUBEmx32 for USB HOST and HID (Human Interface Host Class) , but when i connect a logitech keyboard i have a strange problem of comunication. 

I have continuos problem of frame timing jitter (logged with USB beagle 480)

It's normal this error ? Someone know how resolve this ? 

In attachment the screen of the problem on USB logger.

Sorry for my english

#host #low-speed #low-speed #host #usb #usb
4 REPLIES 4
tsuneo
Senior
Posted on August 13, 2016 at 20:16

The beagle 480 trace suggests that the keep-alive cycle is slightly longer than the expected tolerance.

On low-speed bus, periodical keep-alive (EOP) is issued by host at the timing of  SOF. The USB2.0 spec defines the SOF periodicity as 1ms +/- 500ns. And then, the keep-alive cycle is also expected in this tolerance.

If your F415 host is running on the internal OSC (HSI), assign an external crystal (HSE), instead.

If it would be running on HSE, replace the crystal with more accurate one.

Tsuneo

Marco1
Associate II
Posted on August 18, 2016 at 11:34

Hi Tsuneo, 

thank you for support, i'm using 24mhz external crystal, and i tryed to change it, but the problem is present. 

USB work, but beagle signals a big ammount of errors.

Can be, otherwise, a configuration problem ?

Thank you again

Marco

tsuneo
Senior
Posted on August 23, 2016 at 17:29

Hi marco,

1) Testing on my side, I tested this issue on my F4 discovery board with Cube, - CubeMX: v4.0 - CubeF4: v1.0 A HID USB host was generated using CubeMX. The STM32 host had successfully enumerated a low-speed mouse (with a minor fix **1) On this setup, the keep-alive interval was measured on a hardware bus analyzer. - 90 cycles of keep-alive were 35 micro-sec longer, relatively to the analyzer's internal clock. that is, about 389 ns per cycle. This figure satisfies the USB spec's tolerance (+/-500ns), but it seems slightly greater than expected, while they are running on crystals. Deviation of crystal OSC should be expected within 100ppm in room temperature. **1) a minor fix Two calls of HAL_GPIO_WritePin() were added to USBH_LL_DriverVBUS(), ''USER CODE'' section, to control VBUS power switch chip.

usbh_conf.h
line: 398
USBH_StatusTypeDef USBH_LL_DriverVBUS (USBH_HandleTypeDef *phost, uint8_t state)
{ 
/* USER CODE BEGIN 0 */
/* USER CODE END 0*/ 
if (phost->id == HOST_FS) 
{ 
if (state == 0)
{ 
/* Drive high Charge pump */
/* ToDo: Add IOE driver control */ 
/* USER CODE BEGIN DRIVE_HIGH_CHARGE_FOR_FS */
// the enable pin of the power switch chip is active-low
HAL_GPIO_WritePin(OTG_FS_PowerSwitchOn_GPIO_Port, OTG_FS_PowerSwitchOn_Pin, GPIO_PIN_SET);
/* USER CODE END DRIVE_HIGH_CHARGE_FOR_FS */ 
} 
else
{
/* Drive low Charge pump */
/* ToDo: Add IOE driver control */ 
/* USER CODE BEGIN DRIVE_LOW_CHARGE_FOR_FS */
HAL_GPIO_WritePin(OTG_FS_PowerSwitchOn_GPIO_Port, OTG_FS_PowerSwitchOn_Pin, GPIO_PIN_RESET);
/* USER CODE END DRIVE_HIGH_CHARGE_FOR_FS */ 
}
} 
HAL_Delay(200);
return USBH_OK; 
}

2) Tuning of Keep-Alive / SOF interval You may reduce this interval on the firmware. Reduce this figure by ONE or TWO.

stm32f4xx_ll_usb.c
line:1222
HAL_StatusTypeDef USB_InitFSLSPClkSel(USB_OTG_GlobalTypeDef *USBx , uint8_t freq)
{
USBx_HOST->HCFG &= ~(USB_OTG_HCFG_FSLSPCS);
USBx_HOST->HCFG |= (freq & USB_OTG_HCFG_FSLSPCS);
if (freq == HCFG_48_MHZ)
{
USBx_HOST->HFIR = (uint32_t)48000U; // <---- 47999U, for full-speed
}
else if (freq == HCFG_6_MHZ)
{
USBx_HOST->HFIR = (uint32_t)6000U; // <---- 5999U, for low-speed
} 
return HAL_OK; 
}

Tsuneo
Marco1
Associate II
Posted on August 24, 2016 at 11:01

Hi, Tsuneo, 

Solved with your fix (n.2)... I put 5999U and 47999U and now work perfectly !!

Many Many thanks for your help !!

Marco