中级会员
- 积分
- 223
- 威望
- 111
- 贡献
- 50
- 兑换币
- 55
- 注册时间
- 2014-1-21
- 在线时间
- 31 小时
- 毕业学校
- 中国计量学院
|
8#
楼主 |
发表于 2014-1-21 21:30:53
|
只看该作者
tobeabh 发表于 2014-1-21 19:02
发下你串口的发送函数
void uart_init (UARTn uartn, u32 baud)
{
register uint16 sbr, brfa;
uint8 temp;
u32 sysclk; //时钟
/* 配置 UART功能的 GPIO 接口 开启时钟 */
switch(uartn)
{
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_RXD
else if(UART0_TX == PTA14)
PORTA_PCR14 = PORT_PCR_MUX(0x3); //在PTA14上使能UART0_RXD
else if(UART0_TX == PTB17)
PORTB_PCR17 = PORT_PCR_MUX(0x3); //在PTB17上使能UART0_RXD
else if(UART0_TX == PTD7)
PORTD_PCR7 = PORT_PCR_MUX(0x3); //在PTD7上使能UART0_RXD
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_RXD
else if(UART1_TX == PTE0)
PORTE_PCR0 = PORT_PCR_MUX(0x3); //在PTE0上使能UART1_RXD
else
assert_failed(__FILE__, __LINE__); //设置管脚有误?
SIM_SCGC4 |= SIM_SCGC4_UART1_MASK;
break;
是这个吗,我用的是uart1
|
|