板子是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...呀?是怎么回事呀
|