我用的板子是TM4C1294NCPD 我想配置PJ0接口链接switch1,输入模式,并且使用下拉电阻。 一下是我的配置代码,但是我下载到板子后,按下开关,PJ0电压依然为0.
void SW_Init(void){
SYSCTL->RCGCGPIO |= 0x00000100; // activate clock for Port J
while((SYSCTL->PRGPIO&0x00000100) == 0){;} // allow time for clock to stabilize
GPIOJ_AHB->DIR &= ~0x01; // make PJ0 in //& PJ1 in
GPIOJ_AHB->AFSEL &= ~0x01; // disable alt funct on PJ0 & PJ1
GPIOJ_AHB->PUR |= 0x00; // disable pull-up on PJ0
GPIOJ_AHB->PDR |= 0x01; // enable pull-down on PJ0
GPIOJ_AHB->DEN |= 0x01; // enable digital I/O on PJ0 //& PJ1
GPIOJ_AHB->AMSEL &= ~0x01; // disable analog functionality on PJ0 //& PJ1
GPIOJ_AHB->PCTL = (GPIOJ_AHB->PCTL & 0xFFFFFFF0)+0x00000000;
GPIOJ_AHB->IM &=~0x01; // Clear GPIOM before programming GPIOS,GPIOBE,GPIOEV
GPIOJ_AHB->ICR|= 0x01; // Clear Interrupt Flag
GPIOJ_AHB->IS &=~0x01; // PJ0 is edge-sensitive //& PJ1 are
GPIOJ_AHB->IBE &=~0x01; // PJ0 & PJ1 Interrupt is triggered by single edge
// GPIOJ_AHB->IEV &=~0x01; // PJ0 Interrupt is triggered by falling edge
GPIOJ_AHB->IEV |= 0x01; // PJ0 Interrupt is triggered by rising edge
GPIOJ_AHB->IM |= 0x01; // Enable PJ0 //& PJ1
NVIC_EN1_R |=0x00080000; // Enable Interrupt number 51 which is bit 19 in EN1
NVIC_PRI12_R = (NVIC_PRI12_R&0x00FFFFFF)|0x80000000; //Set the priority value to 4 in INTD of PRI12 Register. (page 159/160)
}
Nancy Wang:
请去mcu论坛咨询。
e2echina.ti.com/…/