金牌会员
- 积分
- 1923
- 威望
- 987
- 贡献
- 572
- 兑换币
- 632
- 注册时间
- 2013-8-29
- 在线时间
- 182 小时
|
这是串口通讯uart里的初始化程序里的一段程序,现在只有uart1能使用,其他的不能通讯啊,我看了UART2和UART1的配置都不一样,是否我的这个有错误 啊,下面红色的语句是什么意思呢?如果我想定义成其他引脚需要怎么改,需不需要改变红色语句里的数值?,,救命!@火哥
case UART0:
if(UART0_RX == PTA1)
PORTA_PCR1 = PORT_PCR_MUX(0x2); //在PTA1上使能UART0_RXD
else if(UART0_RX == PTA15)
PORTA_PCR15 = PORT_PCR_MUX(0x3); //在PTA15上使能UART0_RXD
else if(UART0_RX == PTB16)
PORTB_PCR16 = PORT_PCR_MUX(0x3); //在PTB16上使能UART0_RXD
else if(UART0_RX == PTD6)
PORTD_PCR6 = PORT_PCR_MUX(0x3); //在PTD6上使能UART0_RXD
else
assert_failed(__FILE__, __LINE__); //设置管脚有误?
if(UART0_TX == PTA2)
PORTA_PCR2 = PORT_PCR_MUX(0x2); //在PTA2上使能UART0_TXD
else if(UART0_TX == PTA14)
PORTA_PCR14 = PORT_PCR_MUX(0x3); //在PTA14上使能UART0_TXD
else if(UART0_TX == PTB17)
PORTB_PCR17 = PORT_PCR_MUX(0x3); //在PTB17上使能UART0_TXD
else if(UART0_TX == PTD7)
PORTD_PCR7 = PORT_PCR_MUX(0x3); //在PTD7上使能UART0_TXD
else
assert_failed(__FILE__, __LINE__); //设置管脚有误?
SIM_SCGC4 |= SIM_SCGC4_UART0_MASK; //使能 UARTn 时钟
break;
case UART1:
if(UART1_RX == PTC3)
PORTC_PCR3 = PORT_PCR_MUX(0x3); //在PTC3上使能UART1_RXD 优先接线
else if(UART1_RX == PTE1)
PORTE_PCR1 = PORT_PCR_MUX(0x3); //在PTE1上使能UART1_RXD
else
assert_failed(__FILE__, __LINE__); //设置管脚有误?
if(UART1_TX == PTC4)
PORTC_PCR4 = PORT_PCR_MUX(0x3); //在PTC4上使能UART1_TXD 优先接线
else if(UART1_TX == PTE0)
PORTE_PCR0 = PORT_PCR_MUX(0x3); //在PTE0上使能UART1_TXD
else
assert_failed(__FILE__, __LINE__); //设置管脚有误?
SIM_SCGC4 |= SIM_SCGC4_UART1_MASK;
break;
case UART2:
PORTD_PCR3 = PORT_PCR_MUX(0x3); //在PTD3上使能UART2_TXD功能
PORTD_PCR2 = PORT_PCR_MUX(0x3); //在PTD2上使能UART2_RXD
SIM_SCGC4 |= SIM_SCGC4_UART2_MASK;
break;
case UART3:
if(UART3_RX == PTB10)
PORTB_PCR10 = PORT_PCR_MUX(0x3); //在PTB10上使能UART3_RXD
else if(UART3_RX == PTC16)
PORTC_PCR16 = PORT_PCR_MUX(0x3); //在PTC16上使能UART3_RXD
else
if(UART3_RX == PTE5)
PORTE_PCR5 = PORT_PCR_MUX(0x3); //在PTE5上使能UART3_RXD 2013-12-03将这部分注释
else
assert_failed(__FILE__, __LINE__); //设置管脚有误?
if(UART3_TX == PTB11)
PORTB_PCR11 = PORT_PCR_MUX(0x3); //在PTB11上使能UART3_RXD
else if(UART3_TX == PTC17)
PORTC_PCR17 = PORT_PCR_MUX(0x3); //在PTC17上使能UART3_RXD
else if(UART3_TX == PTE4)
PORTE_PCR4 = PORT_PCR_MUX(0x3); //在PTE4上使能UART3_RXD
else
assert_failed(__FILE__, __LINE__); //设置管脚有误?
SIM_SCGC4 |= SIM_SCGC4_UART3_MASK;
break;
|
|