高级会员

- 积分
- 785
- 金钱
- 785
- 注册时间
- 2016-3-3
- 在线时间
- 28 小时
|
1金钱
STM32F767到手一个多月了,前两天正式开始玩
/**
* @brief General Purpose I/O
*/
typedef struct
{
__IO uint32_t MODER; /*!< GPIO port mode register, Address offset: 0x00 */
__IO uint32_t OTYPER; /*!< GPIO port output type register, Address offset: 0x04 */
__IO uint32_t OSPEEDR; /*!< GPIO port output speed register, Address offset: 0x08 */
__IO uint32_t PUPDR; /*!< GPIO port pull-up/pull-down register, Address offset: 0x0C */
__IO uint32_t IDR; /*!< GPIO port input data register, Address offset: 0x10 */
__IO uint32_t ODR; /*!< GPIO port output data register, Address offset: 0x14 */
__IO uint32_t BSRR; /*!< GPIO port bit set/reset register, Address offset: 0x18 */
__IO uint32_t LCKR; /*!< GPIO port configuration lock register, Address offset: 0x1C */
__IO uint32_t AFR[2]; /*!< GPIO alternate function registers, Address offset: 0x20-0x24 */
} GPIO_TypeDef;
这段函数中,我是知道
#define GPIOA ((GPIO_TypeDef *) GPIOA_BASE)
#define GPIOA_BASE (AHB1PERIPH_BASE + 0x0000U)
然后,找了一会程序,想了一会,没想明白或者没找到这个结构体是如何实现地址偏移的,有路过的大神求指导
|
-
最佳答案
查看完整内容[请看2#楼]
在Project-> Setting-> C/C++-> Code Generation-> Struct member alignment中可以设置结构的对齐方式。
进入VS2005的菜单Tools->Options,选择Debugging->General 勾上 Enable address-level debugging 选项 和 Require source files to exactly match the original version。查看窗口 memory(Debug -> windows -> memory)
在调试时下断点~然后在监视窗口键入 &变量名 来查看变量地址~也可以直接将 &变量名 的值写 ...
|