【MCXA156开发板测评】-1-开发环境搭建与串口回显
[复制链接]
本帖最后由 慕容雪花 于 2024-12-31 22:24 编辑
非常感谢EEWorld与NXP提供的本次MCXA156开发板的测评体验机会。在今年最后一天先开个箱,搭建一下环境。剩下的交给明年了!
外包装盒新款的NXP三色log
板子布局紧凑合理,不仅提供了多种接口比如Arduino UNO R3接口、PMOD接口还有Mikro BUS接口,以及NXP自家的Flexio LCD接口,可以方便的跟NXP Semiconductors LCD-PAR-S035模块搭配使用。
主控芯片上MCXA156,这是一颗主频可以高达96MHz的Cortex-m33内核的高性能、高安全特性NXP新品。主要应用在工业控制以及电机控制领域。板子的调试芯片上LPC55S69,双核Cortex-M33,感觉比MCXA156更厉害。
开发板上电,首先查看设备管理器中是否有MCU-Link VCom Port (COM xx),xx是随机的,每台机器或许不一样。
这个虚拟串口就是LPC55S69当作MCU-Link,起到USB跟板载LPUART0的一个桥接作用。
看到D12 RGB小灯1s间隔闪烁,D6小灯在呼吸。
1126989859
板载的连接器资源可以参考如下官方图:
开发环境的搭建一定要遵循新板子使用新软件,这样最新的BSP以及BUG都得到了很好的修复,可以让用户专注于业务代码的开发,避免在官方已经修复的BUG上面重复浪费自己宝贵的开发时间。
安装成功后,打开最新版本的IDE,选择开发板型号,开始远程导入官方SDK。
在导入工程界面,选择一个经典的“hello world”。NXP官方的IDE都是内置了自家的配置工具叫:Config Tool。
打开导入的项目后,点击mex后缀的文件即可进入图形化配置界面。
查看本次即将体验的LPUART0打印HELLO WORLD的外设配置:
代码:
void BOARD_InitPins(void)
{
/* PORT0: Peripheral clock is enabled */
CLOCK_EnableClock(kCLOCK_GatePORT0);
/* LPUART0 peripheral is released from reset */
RESET_ReleasePeripheralReset(kLPUART0_RST_SHIFT_RSTn);
/* PORT0 peripheral is released from reset */
RESET_ReleasePeripheralReset(kPORT0_RST_SHIFT_RSTn);
const port_pin_config_t port0_2_pin78_config = {/* Internal pull-up resistor is enabled */
kPORT_PullUp,
/* Low internal pull resistor value is selected. */
kPORT_LowPullResistor,
/* Fast slew rate is configured */
kPORT_FastSlewRate,
/* Passive input filter is disabled */
kPORT_PassiveFilterDisable,
/* Open drain output is disabled */
kPORT_OpenDrainDisable,
/* Low drive strength is configured */
kPORT_LowDriveStrength,
/* Normal drive strength is configured */
kPORT_NormalDriveStrength,
/* Pin is configured as LPUART0_RXD */
kPORT_MuxAlt2,
/* Digital input enabled */
kPORT_InputBufferEnable,
/* Digital input is not inverted */
kPORT_InputNormal,
/* Pin Control Register fields [15:0] are not locked */
kPORT_UnlockRegister};
/* PORT0_2 (pin 78) is configured as LPUART0_RXD */
PORT_SetPinConfig(PORT0, 2U, &port0_2_pin78_config);
const port_pin_config_t port0_3_pin79_config = {/* Internal pull-up resistor is enabled */
kPORT_PullUp,
/* Low internal pull resistor value is selected. */
kPORT_LowPullResistor,
/* Fast slew rate is configured */
kPORT_FastSlewRate,
/* Passive input filter is disabled */
kPORT_PassiveFilterDisable,
/* Open drain output is disabled */
kPORT_OpenDrainDisable,
/* Low drive strength is configured */
kPORT_LowDriveStrength,
/* Normal drive strength is configured */
kPORT_NormalDriveStrength,
/* Pin is configured as LPUART0_TXD */
kPORT_MuxAlt2,
/* Digital input enabled */
kPORT_InputBufferEnable,
/* Digital input is not inverted */
kPORT_InputNormal,
/* Pin Control Register fields [15:0] are not locked */
kPORT_UnlockRegister};
/* PORT0_3 (pin 79) is configured as LPUART0_TXD */
PORT_SetPinConfig(PORT0, 3U, &port0_3_pin79_config);
}
串口初始化:
status_t DbgConsole_Init(uint8_t instance, uint32_t baudRate, serial_port_type_t device, uint32_t clkSrcFreq)
{
hal_uart_config_t usrtConfig;
if (kSerialPort_Uart != device)
{
return kStatus_Fail;
}
/* Set debug console to initialized to avoid duplicated initialized operation. */
s_debugConsole.serial_port_type = device;
usrtConfig.srcClock_Hz = clkSrcFreq;
usrtConfig.baudRate_Bps = baudRate;
usrtConfig.parityMode = kHAL_UartParityDisabled;
usrtConfig.stopBitCount = kHAL_UartOneStopBit;
usrtConfig.enableRx = 1U;
usrtConfig.enableTx = 1U;
usrtConfig.enableRxRTS = 0U;
usrtConfig.enableTxCTS = 0U;
usrtConfig.instance = instance;
#if (defined(HAL_UART_ADAPTER_FIFO) && (HAL_UART_ADAPTER_FIFO > 0u))
usrtConfig.txFifoWatermark = 0U;
usrtConfig.rxFifoWatermark = 0U;
#endif
/* Enable clock and initial UART module follow user configure structure. */
(void)HAL_UartInit((hal_uart_handle_t)&s_debugConsole.uartHandleBuffer[0], &usrtConfig);
/* Set the function pointer for send and receive for this kind of device. */
s_debugConsole.putChar = HAL_UartSendBlocking;
s_debugConsole.getChar = HAL_UartReceiveBlocking;
return kStatus_Success;
}
主代码:
int main(void)
{
char ch;
/* Init board hardware. */
BOARD_InitPins();
BOARD_InitBootClocks();
BOARD_InitDebugConsole();
PRINTF("hello eeworld.\r\n");
while (1)
{
ch = GETCHAR();
PUTCHAR(ch);
}
}
点击菜单栏上的锤子按钮,编译:
Building target: frdmmcxa156_hello_world.axf
Invoking: MCU Linker
arm-none-eabi-gcc -nostdlib -Xlinker -no-warn-rwx-segments -Xlinker -Map="frdmmcxa156_hello_world.map" -Xlinker --gc-sections -Xlinker -print-memory-usage -Xlinker --sort-section=alignment -Xlinker --cref -mcpu=cortex-m33 -mfpu=fpv5-sp-d16 -mfloat-abi=hard -mthumb -T frdmmcxa156_hello_world_Debug.ld -o "frdmmcxa156_hello_world.axf" ./utilities/fsl_assert.o ./utilities/fsl_debug_console.o ./utilities/fsl_memcpy.o ./utilities/fsl_str.o ./startup/startup_mcxa156.o ./source/hello_world.o ./source/semihost_hardfault.o ./drivers/fsl_clock.o ./drivers/fsl_common.o ./drivers/fsl_common_arm.o ./drivers/fsl_gpio.o ./drivers/fsl_lpuart.o ./drivers/fsl_reset.o ./drivers/fsl_spc.o ./device/system_MCXA156.o ./component/uart/fsl_adapter_lpuart.o ./component/lists/fsl_component_generic_list.o ./board/board.o ./board/clock_config.o ./board/pin_mux.o
Memory region Used Size Region Size %age Used
PROGRAM_FLASH: 11820 B 1 MB 1.13%
SRAM: 8444 B 120 KB 6.87%
SRAMX: 0 GB 12 KB 0.00%
Finished building target: frdmmcxa156_hello_world.axf
Performing post-build steps
arm-none-eabi-size 'frdmmcxa156_hello_world.axf'; arm-none-eabi-objcopy -v -O binary 'frdmmcxa156_hello_world.axf' 'frdmmcxa156_hello_world.bin'
text data bss dec hex filename
11812 8 8436 20256 4f20 frdmmcxa156_hello_world.axf
copy from `frdmmcxa156_hello_world.axf' [elf32-littlearm] to `frdmmcxa156_hello_world.bin' [binary]
22:04:59 Build Finished. 0 errors, 0 warnings. (took 10s.918ms)
点击蓝色小虫子
debug按钮,然后全速运行
。打开串口助手:
|