【简介】
我们在之前的帖子介绍过S32K1系列的MCU的UART 的使用(https://forum.eepw.com.cn/thread/393077/1),查看S32K3 的UART 的框图,IP 在设计上和S32K1 看上去是一致的。

我么继续使用S32DS来创建一个uart 工程来验证uart 输出功能。
【工程创建】
S32DS 下创建一个APP 程序选择对应的芯片型号jiproject 名称即可

根据个人配置选择SDK版本及使用的lib 类型,这样就创建完了工程

【时钟配置】
创建好工程后我们来配置时钟,Core 我们配置为使用内部FIRC 时钟源

本次试验使用UART6 的串口对应时钟配置如下

【PIN MUX 配置】

【UART 参数配置】

配置完成后生成初始化代码

初始化代码生成后,添加如下代码打印“hello world\r\n” 验证串口输出功能。
/* Including necessary configuration files. */
#include "Clock_Ip.h"
#include "Lpuart_Uart_Ip.h"
#include "Siul2_Port_Ip.h"
/* User includes */
/*!
\brief The main function for the project.
\details The startup initialization sequence is the following:
* - startup asm routine
* - main()
*/
int main(void)
{
/* Initialize the clock driver */
Clock_Ip_Init(Clock_Ip_aClockConfig);
/* Initialize all pins using the Port driver */
Siul2_Port_Ip_Init(NUM_OF_CONFIGURED_PINS_PortContainer_0_BOARD_InitPeripherals, g_pin_mux_InitConfigArr_PortContainer_0_BOARD_InitPeripherals);
Lpuart_Uart_Ip_Init(6,&Lpuart_Uart_Ip_xHwConfigPB_6);
/* Enable the LPUART transmitter */
Lpuart_Uart_Ip_SetTransmitterCmd(IP_LPUART_6,true);
/* Enable the LPUART receiver */
Lpuart_Uart_Ip_SetReceiverCmd(IP_LPUART_6, true);
char * ptr = "hello world\r\n";
for (int i = 0; i < 13; i++)
{
while((IP_LPUART_6->STAT & LPUART_STAT_TC_MASK)>>LPUART_STAT_TC_SHIFT==0);
IP_LPUART_6->DATA = *ptr;
ptr++;
}
return 0;
}下载运行后串口已经按照预期的打印输出“hello world”

我要赚赏金
