|
板子是stm32F103C8T6最小系統(tǒng)
#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));//通過置位寄存器設(shè)置1改變C14引腳輸出高電平
while(1){
}
運行結(jié)果沒問題,通過仿真調(diào)試查看內(nèi)存地址 0x4001100c, 這個應(yīng)該就是實際的數(shù)據(jù)地址吧,就是GPIOC_ODR吧? 那值應(yīng)該是 40 00...(0100 0000..)呀,但是怎么跑到地址 0x4001100d去了?如果要加上高16位的話,也應(yīng)該是 00 00 40 00...呀?是怎么回事呀
stm32.PNG (10.99 KB, 下載次數(shù): 16)
下載附件
2022-9-2 14:34 上傳
|
|