2023-11-06 12:25 PM
They are defined like this in stm32h563xx.h:
/*Buffer Descriptor Mask*/
#define USB_PMA_TXBD_ADDMSK                        (0xFFFF0000UL)
#define USB_PMA_TXBD_COUNTMSK                      (0x0000FFFFUL)
#define USB_PMA_RXBD_ADDMSK                        (0xFFFF0000UL)
#define USB_PMA_RXBD_COUNTMSK                      (0x03FFFFFFUL)ADDMSKs are correct, but I was expecting both COUNTMSK to be 0xFC00FFFFUL since both COUNT_TX and COUNT_RX are 10 bits [25:16]. When double buffering is used there is BLSIZE and NUM_BLOCK but I dont see anything about these in the header. Is there a reason the TXBD and RXBD_COUNTMSK are defined like this ?
2023-11-08 2:00 AM
Hello @mete ,
i'm checking this out i will come back to you as soon as possible .
BR
Hichem
2023-11-09 8:11 AM
Hello @mete
after investigation on this matter i have the following informations :
#define USB_DRD_SET_CHEP_TX_CNT(USBx,bEpChNum, wCount) \
do { \
/* Reset old TX_Count value */ \
(USB_DRD_PMA_BUFF + (bEpChNum))->TXBD &= USB_PMA_TXBD_COUNTMSK; \
\
/* Set the wCount in the dedicated EP_TXBuffer */ \
(USB_DRD_PMA_BUFF + (bEpChNum))->TXBD |= (uint32_t)((uint32_t)(wCount) << 16U); \
} while(0)
Internal ticket number: 165995 (This is an internal tracking number and is not accessible or usable by customers).
this has no effect on the HAL implementation of USB as this mask is not used so using the HAL you shouldn't have any issues .
BR
2025-10-10 3:30 AM
Hi @mete
The mask USB_PMA_RXBD_COUNTMSK = 0x03FFFFFFUL ensures that when you read or write the RX count, these bits are preserved and not accidentally cleared or overwritten. This was meant to avoid corrupting the actual data length information.
So, the RX count mask keeps bits [25:16] because these bits directly represent the valid received data length from the host. Maintaining this mask ensures accurate tracking of incoming data size.
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.
