板子是stm32F103C8T6最小系统
#define PERIPH_BASE ((unsigned int)0x40000000)
#define APB1PERIPH_BASE (PERIPH_BASE + 0x20000)
#define APB2PERIPH_BASE (PERIPH_BASE + 0x10000)
#define GPIOC_BASE (APB2PERIPH_BASE + 0x1000)
#define GPIOC_CRL *(unsigned int*)(GPIOC_BASE + 0x00)
#define GPIOC_CRH *(unsigned int*)(GPIOC_BASE + 0x04)
#define GPIOC_ODR *(unsigned int*)(GPIOC_BASE + 0x0c)
#define GPIOC_BSRR *(unsigned int*)(GPIOC_BASE + 0x10)
#define RCC_BASE (APB1PERIPH_BASE + 0x1000)
#define RCC_APB2ENR *(unsigned int*)(RCC_BASE + 0x18)
main.c:
RCC_APB2ENR |= 1<<4;
GPIOC_CRH &=~(0x0f<<(4*6));
GPIOC_CRH |=(0x01<<(4*6));
GPIOC_BSRR = (1<<(14));//通过置位寄存器设置1改变C14引脚输出高电平
while(1){
}
运行结果没问题,通过仿真调试查看内存地址 0x4001100c, 这个应该就是实际的数据地址吧,就是GPIOC_ODR吧? 那值应该是 40 00...(0100 0000..)呀,但是怎么跑到地址 0x4001100d去了?如果要加上高16位的话,也应该是 00 00 40 00...呀?是怎么回事呀
|