2018-05-01 02:12 PM
Is the code in HAL_PCDEx_SetTxFiFo() within stm32f7xx_hal_pcd_ex.c correct?
The datasheet says:
OTG device IN endpoint transmit FIFO size register
(OTG_DIEPTXFx) (x = 1..5[FS] /8[HS], where x is theFIFO_number)Bits 31:16 INEPTXFD: IN endpoint Tx FIFO depth
This value is in terms of 32-bit words.Minimum value is 16Bits 15:0 INEPTXSA: IN endpoint FIFOx transmit RAM start addressThis field contains the memory start address for IN endpoint transmit FIFOx. The addressmust be aligned with a 32-bit memory location.However, HAL_PCDEx_SetTxFiFo isn't doing that (comments removed for brevity.)
HAL_StatusTypeDef HAL_PCDEx_SetTxFiFo(PCD_HandleTypeDef *hpcd, uint8_t fifo, uint16_t size)
{ uint8_t i = 0; uint32_t Tx_Offset = 0;Tx_Offset = hpcd->Instance->GRXFSIZ;
if(fifo == 0) { hpcd->Instance->DIEPTXF0_HNPTXFSIZ = (uint32_t)(((uint32_t)size << 16) | Tx_Offset); } else { Tx_Offset += (hpcd->Instance->DIEPTXF0_HNPTXFSIZ) >> 16; for (i = 0; i < (fifo - 1); i++) { Tx_Offset += (hpcd->Instance->DIEPTXF[i] >> 16); } hpcd->Instance->DIEPTXF[fifo - 1] = (uint32_t)(((uint32_t)size << 16) | Tx_Offset); } return HAL_OK;}i.e. the lower 16bits are addresses in bytes ; the upper 16bits are FIFO sizes in number of 32bit words.
There is no distinction in the HAL code between addresses which are in bytes and FIFO size which must be in 32bit words. The code ought to be multiplying by four for the Tx_Offset.
e.g.
Tx_Offset = hpcd->Instance->GRXFSIZ << 2;
and
Tx_Offset += (hpcd->Instance->DIEPTXF[i] >> 14);
I had been using Cube 1.9.0, but the same code is in 1.11.0.
If the code is correct, please educate me!
James
2018-05-09 02:23 PM
Any thoughts on this from ST ?
James
2018-06-19 12:13 PM
Did anyone get any clarification from ST on this? I'm wondering the same thing.
-Brian
2018-06-19 12:22 PM
This is a documentation problem, not problem in the library.
https://community.st.com/0D50X00009XkZFSSA3
JW