реклама на сайте
подробности

 
 
> STM32F3xx, USB, “1 x 16 bits/word” access scheme, Что это, и где определено?
ViKo
сообщение Jun 17 2015, 20:15
Сообщение #1


Универсальный солдатик
******

Группа: Модераторы
Сообщений: 8 634
Регистрация: 1-11-05
Из: Минск
Пользователь №: 10 362



Читаю RM0316, раздел USB, 32.6.3 Buffer descriptor table:
Цитата
In the following pages, two address locations are reported for devices with “1 x 16 bits/word”
access scheme: the one to be used by application software while accessing the packet
memory, and the local one relative to USB peripheral access. To obtain the correct memory
address value to be used in the application software while accessing the packet memory,
the actual memory location address must be multiplied by two.
On devices with “2 x 16 bits/word” access scheme, the address location to be used by
application software is the same as the local one relative to USB peripheral access. The
packet memory on these devices should be accessed only by byte (8-bit) or half-word (16-
bit) accesses. Word (32-bit) accesses are not allowed.

Допустим, понять еще... ладно, и понять не могу biggrin.gif И узнать, какому MCU какая схема соответствует.
Кубописатели в stm32f3xx_hal_pcd_ex.h предлагают такое решение:
CODE

/**
* @brief Gets address in an endpoint register.
* @param USBx: USB peripheral instance register address.
* @param bEpNum: Endpoint Number.
* @retval None
*/

#if defined(STM32F302xC) || defined(STM32F303xC) || \
defined(STM32F373xC)

#define PCD_EP_TX_ADDRESS(USBx, bEpNum) ((uint32_t *)((USBx->BTABLE+bEpNum*8)*2+ ((uint32_t)USBx + 0x400)))
#define PCD_EP_TX_CNT(USBx, bEpNum) ((uint32_t *)((USBx->BTABLE+bEpNum*8+2)*2+ ((uint32_t)USBx + 0x400)))
#define PCD_EP_RX_ADDRESS(USBx, bEpNum) ((uint32_t *)((USBx->BTABLE+bEpNum*8+4)*2+ ((uint32_t)USBx + 0x400)))
#define PCD_EP_RX_CNT(USBx, bEpNum) ((uint32_t *)((USBx->BTABLE+bEpNum*8+6)*2+ ((uint32_t)USBx + 0x400)))

#define PCD_SET_EP_RX_CNT(USBx, bEpNum,wCount) {\
uint32_t *pdwReg = PCD_EP_RX_CNT(USBx, bEpNum); \
PCD_SET_EP_CNT_RX_REG(pdwReg, wCount);\
}

#endif /* STM32F302xC || STM32F303xC || */
/* STM32F373xC */


#if defined(STM32F302xE) || defined(STM32F303xE) || \
defined(STM32F302x8)

#define PCD_EP_TX_ADDRESS(USBx, bEpNum) ((uint16_t *)((USBx->BTABLE+bEpNum*8)+ ((uint32_t)USBx + 0x400)))
#define PCD_EP_TX_CNT(USBx, bEpNum) ((uint16_t *)((USBx->BTABLE+bEpNum*8+2)+ ((uint32_t)USBx + 0x400)))
#define PCD_EP_RX_ADDRESS(USBx, bEpNum) ((uint16_t *)((USBx->BTABLE+bEpNum*8+4)+ ((uint32_t)USBx + 0x400)))
#define PCD_EP_RX_CNT(USBx, bEpNum) ((uint16_t *)((USBx->BTABLE+bEpNum*8+6)+ ((uint32_t)USBx + 0x400)))

#define PCD_SET_EP_RX_CNT(USBx, bEpNum,wCount) {\
uint16_t *pdwReg = PCD_EP_RX_CNT(USBx, bEpNum); \
PCD_SET_EP_CNT_RX_REG(pdwReg, wCount);\
}

Но откуда они узнали? Где написано?
Что-то я впадаю в депрессию при попытках разобраться с USB в STM32...
Go to the top of the page
 
+Quote Post
 
Start new topic
Ответов
SSerge
сообщение Jun 18 2015, 10:29
Сообщение #2


Профессионал
*****

Группа: Свой
Сообщений: 1 719
Регистрация: 13-09-05
Из: Novosibirsk
Пользователь №: 8 528



Откуда они узнали не знаю, а Вы можете это посмотреть в разделе 32.3 Table 176.

Все эти странности по одной простой причине: буферная память у них 16-разрядная и её по-разному отображают в адресное пространство процессора.
512-байтный буфер виден кусочками по 16 бит в каждом 32-битном слове, а в девайсах с буфером 1024 байта эти 16-битные слова упакованы по две штуки в слово. Но читать их по-прежнему можно только полусловами, по 16 бит за раз.


--------------------
Russia est omnis divisa in partes octo.
Go to the top of the page
 
+Quote Post



Reply to this topicStart new topic
1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0

 


RSS Текстовая версия Сейчас: 3rd August 2025 - 21:16
Рейтинг@Mail.ru


Страница сгенерированна за 0.01353 секунд с 7
ELECTRONIX ©2004-2016