MKL26 UART0 设置问题

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MKL26 UART0 设置问题

1,066 Views
bishihao
Contributor II

大家好,我在用KINETIS-SDK包

                    和KL26芯片

                    开发UART0收送功能时,老报错,是不是SDK不支持KL26的UART0?

代码大致如下,还是我哪里设置的不对?

uint8_t buf[17] = {0xAA,0x55};
uart_user_config_t uartConfig;
uartConfig.baudRate = 9600;
uartConfig.bitCountPerChar = kUart8BitsPerChar;
uartConfig.parityMode = kUartParityDisabled;
uartConfig.stopBitCount = kUartOneStopBit;
uart_state_t uartState;

   

hardware_init();

   

SIM_SOPT2 |= SIM_SOPT2_PLLFLLSEL_MASK;
SIM_SOPT2 |= SIM_SOPT2_UART0SRC(1);
SIM_SCGC4 |= SIM_SCGC4_UART0_MASK;

   

PORTE_PCR20 |= PORT_PCR_MUX(0x4);                                                 
PORTE_PCR21 |= PORT_PCR_MUX(0x4);

   

UART_DRV_Init(0, &uartState, &uartConfig);
while(1)
{
    UART_DRV_SendData(1,buf,17);
    ;//断点
}
Labels (1)
0 Kudos
5 Replies

682 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Shihao,

在回答你问题之前,我想知道一下你的SDK的版本是多少?

还有你说的收发错误,我知道具体表现是什么样子的呢?


Have a great day,
Ping

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

682 Views
bishihao
Contributor II

您好,版本是 KSDK_1.2.0,没有收发之前进入了个assert,忽略之后就进入了hardfault。

QQ图片20150727104015.pngQQ图片20150727104146.png

0 Kudos

682 Views
neoxiong
NXP Employee
NXP Employee

Hello,

KL26的UART0的对应的IP是LPSCI, 你调用的API应该是LPSCI_DRV_Init (0, ..., ...),请查看并使用ksdk lpsci下的文件

UART1,UART2对应的IP才是UART. 所以UART_DRV_Init只能传入参数1和2, 传0的话因为没有这个外设就会有问题

682 Views
bishihao
Contributor II

谢谢,回复的晚了

0 Kudos

682 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Shihao,

在KSDK1.2中,关于KL26的hello_world工程,本身就在hardware_init();中已经初始化了UART0,所以肯定KL26是支持UART0的。

我建议你可以先在main()中,先禁止使能你自己对UART0的配置,在debug中看看经过hardware_init();后,UART0的寄存器值。

并在下次过程中,禁止hardware_init();中关于对UART0配置的部分,然后使用自己的代码,在debug中看看使用你自己的代码配置后,UART0的寄存器值,

然后比较一下前后两次的差别。


Have a great day,
Ping

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos