Skip to main content
dani
Visitor II
November 25, 2016
Question

How is pmaadress calculated in HAL_PCDEx_PMAConfig?

  • November 25, 2016
  • 2 replies
  • 2091 views
Posted on November 25, 2016 at 10:03

Generating USB CDC example in STM32CubeMX for STM32F103 it creates the following code inside

USBD_LL_Init

():

HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x00 , PCD_SNG_BUF, 0x18);
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x80 , PCD_SNG_BUF, 0x58);
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x81 , PCD_SNG_BUF, 0xC0);
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x01 , PCD_SNG_BUF, 0x110);
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x82 , PCD_SNG_BUF, 0x100);

How are 0x18, x058, x0C0... calculated? I get that they are endpoint positions inside PMA buffer, but could not find the exact calculation. I read RM0008, ''3 USB functional description'' , the closest I get is ''Figure Packet buffer areas with examples of buffer description table locations''
    This topic has been closed for replies.

    2 replies

    slimen
    Visitor II
    November 29, 2016
    Posted on November 29, 2016 at 15:04

    Hello,

    Refer to this

    http://www.st.com/content/ccc/resource/technical/document/user_manual/01/c6/32/df/79/ad/48/32/CD00158241.pdf/files/CD00158241.pdf/jcr:content/translations/en.CD00158241.pdf

    : STM32 USB-FS-Device development kit, maybe this helps you.

    Regards

    Geoffrey1
    Associate III
    December 12, 2016
    Posted on December 12, 2016 at 03:05

    I'm surprised nobody seems to have an answer.  This is definitely not documented either in the Cube HAL or (at least for the stm32f3) reference manual.   Without this key bit of information, it is virtually impossible to build a USB device that doesn't simply used the (rather limited) standard examples.