- UID
- 918377
- 性别
- 男
- 来自
- 汕尾市
|
void UART2_Init()
{
SIM->SCGC4 |= SIM_SCGC4_UART2_MASK;
SIM->SCGC5 |= SIM_SCGC5_PORTD_MASK;
PORTD->PCR[4] =(uint32_t)((PORTD->PCR[4] & (uint32_t)~0x01000000UL) | (uint32_t)0x0300UL);
PORTD->PCR[5] =(uint32_t)((PORTD->PCR[5] & (uint32_t)~0x01000000UL) | (uint32_t)0x0300UL);
UART2->BDH = (156>>8) & 0x1F;//É貨ÌØÂÊ9600bps
UART2->BDL = 156&0xFF;
UART2->C1=0;
UART2->C2 |= UART_C2_RE_MASK|UART_C2_RIE_MASK;
UART2->C2 |= 1<<3;
// NVIC_SetPriority(14,3);
NVIC_EnableIRQ(14);
int main()
{
while(1);
}
void UART2_Handler(void) // UART2_Handler
{
if( (UART2->S1 & UART_S1_RDRF_MASK) != 0)
{
rebuff[0] = UART2->D;
}
为什么配置 NVIC_EnableIRQ(14); 都进不了中断,用查询方式又可以 |
|