Skip to content

Commit 43b6db1

Browse files
peterwangszkartben
authored andcommitted
boards: frdm_mcxa166, frdm_mcxa276: add frdm_mcxa166 and frdm_mcxa276 board
enable board support for frdm_mcxa166 and frdm_mcxa276 Signed-off-by: Peter Wang <[email protected]>
1 parent 5309c93 commit 43b6db1

24 files changed

+1042
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#
2+
# Copyright 2025 NXP
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
7+
zephyr_library()
8+
zephyr_library_sources(board.c)

boards/nxp/frdm_mcxa166/Kconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright 2025 NXP
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config BOARD_FRDM_MCXA166
5+
select BOARD_EARLY_INIT_HOOK
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Copyright 2025 NXP
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config BOARD_FRDM_MCXA166
5+
select SOC_MCXA166
6+
select SOC_PART_NUMBER_MCXA166VLQ

boards/nxp/frdm_mcxa166/board.c

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
/*
2+
* Copyright 2024-2025 NXP
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
#include <zephyr/init.h>
6+
#include <zephyr/device.h>
7+
#include <zephyr/dt-bindings/clock/mcux_lpc_syscon_clock.h>
8+
#include <fsl_clock.h>
9+
#include <fsl_spc.h>
10+
#include <soc.h>
11+
12+
/* Core clock frequency: 180MHz */
13+
#define CLOCK_INIT_CORE_CLOCK 180000000U
14+
#define BOARD_BOOTCLOCKFROHF180M_CORE_CLOCK 180000000U
15+
/* System clock frequency. */
16+
extern uint32_t SystemCoreClock;
17+
18+
void board_early_init_hook(void)
19+
{
20+
uint32_t coreFreq;
21+
spc_active_mode_core_ldo_option_t ldoOption;
22+
spc_sram_voltage_config_t sramOption;
23+
24+
/* Get the CPU Core frequency */
25+
coreFreq = CLOCK_GetCoreSysClkFreq();
26+
27+
/* The flow of increasing voltage and frequency */
28+
if (coreFreq <= BOARD_BOOTCLOCKFROHF180M_CORE_CLOCK) {
29+
/* Set the LDO_CORE VDD regulator level */
30+
ldoOption.CoreLDOVoltage = kSPC_CoreLDO_OverDriveVoltage;
31+
ldoOption.CoreLDODriveStrength = kSPC_CoreLDO_NormalDriveStrength;
32+
(void)SPC_SetActiveModeCoreLDORegulatorConfig(SPC0, &ldoOption);
33+
/* Configure Flash to support different voltage level and frequency */
34+
FMU0->FCTRL =
35+
(FMU0->FCTRL & ~((uint32_t)FMU_FCTRL_RWSC_MASK)) | (FMU_FCTRL_RWSC(0x4U));
36+
/* Specifies the operating voltage for the SRAM's read/write timing margin */
37+
sramOption.operateVoltage = kSPC_sramOperateAt1P2V;
38+
sramOption.requestVoltageUpdate = true;
39+
(void)SPC_SetSRAMOperateVoltage(SPC0, &sramOption);
40+
}
41+
42+
/*!< Set up system dividers */
43+
CLOCK_SetClockDiv(kCLOCK_DivAHBCLK, 1U); /* !< Set SYSCON.AHBCLKDIV divider to value 1 */
44+
CLOCK_SetClockDiv(kCLOCK_DivFRO_HF, 1U); /* !< Set SYSCON.FROHFDIV divider to value 1 */
45+
CLOCK_SetupFROHFClocking(BOARD_BOOTCLOCKFROHF180M_CORE_CLOCK); /*!< Enable FRO HF */
46+
CLOCK_SetupFRO12MClocking(); /*!< Setup FRO12M clock */
47+
48+
CLOCK_AttachClk(kFRO_HF_to_MAIN_CLK); /* !< Switch MAIN_CLK to kFRO_HF */
49+
50+
/* The flow of decreasing voltage and frequency */
51+
if (coreFreq > BOARD_BOOTCLOCKFROHF180M_CORE_CLOCK) {
52+
/* Configure Flash to support different voltage level and frequency */
53+
FMU0->FCTRL =
54+
(FMU0->FCTRL & ~((uint32_t)FMU_FCTRL_RWSC_MASK)) | (FMU_FCTRL_RWSC(0x4U));
55+
/* Specifies the operating voltage for the SRAM's read/write timing margin */
56+
sramOption.operateVoltage = kSPC_sramOperateAt1P2V;
57+
sramOption.requestVoltageUpdate = true;
58+
(void)SPC_SetSRAMOperateVoltage(SPC0, &sramOption);
59+
/* Set the LDO_CORE VDD regulator level */
60+
ldoOption.CoreLDOVoltage = kSPC_CoreLDO_OverDriveVoltage;
61+
ldoOption.CoreLDODriveStrength = kSPC_CoreLDO_NormalDriveStrength;
62+
(void)SPC_SetActiveModeCoreLDORegulatorConfig(SPC0, &ldoOption);
63+
}
64+
65+
/*!< Set up clock selectors - Attach clocks to the peripheries */
66+
CLOCK_AttachClk(kCPU_CLK_to_TRACE); /* !< Switch TRACE to CPU_CLK */
67+
68+
/*!< Set up dividers */
69+
CLOCK_SetClockDiv(kCLOCK_DivFRO_LF, 1U); /* !< Set SYSCON.FROLFDIV divider to value 1 */
70+
CLOCK_SetClockDiv(kCLOCK_DivWWDT0, 1U); /* !< Set MRCC.WWDT0_CLKDIV divider to value 1 */
71+
CLOCK_SetClockDiv(kCLOCK_DivTRACE, 2U); /* !< Set MRCC.TRACE_CLKDIV divider to value 2 */
72+
73+
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(porta))
74+
RESET_ReleasePeripheralReset(kPORT0_RST_SHIFT_RSTn);
75+
CLOCK_EnableClock(kCLOCK_GatePORT0);
76+
#endif
77+
78+
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(portb))
79+
RESET_ReleasePeripheralReset(kPORT1_RST_SHIFT_RSTn);
80+
CLOCK_EnableClock(kCLOCK_GatePORT1);
81+
#endif
82+
83+
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(portc))
84+
RESET_ReleasePeripheralReset(kPORT2_RST_SHIFT_RSTn);
85+
CLOCK_EnableClock(kCLOCK_GatePORT2);
86+
#endif
87+
88+
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(portd))
89+
RESET_ReleasePeripheralReset(kPORT3_RST_SHIFT_RSTn);
90+
CLOCK_EnableClock(kCLOCK_GatePORT3);
91+
#endif
92+
93+
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(porte))
94+
RESET_ReleasePeripheralReset(kPORT4_RST_SHIFT_RSTn);
95+
CLOCK_EnableClock(kCLOCK_GatePORT4);
96+
#endif
97+
98+
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(gpio0))
99+
RESET_ReleasePeripheralReset(kGPIO0_RST_SHIFT_RSTn);
100+
CLOCK_EnableClock(kCLOCK_GateGPIO0);
101+
#endif
102+
103+
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(gpio1))
104+
RESET_ReleasePeripheralReset(kGPIO1_RST_SHIFT_RSTn);
105+
CLOCK_EnableClock(kCLOCK_GateGPIO1);
106+
#endif
107+
108+
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(gpio2))
109+
RESET_ReleasePeripheralReset(kGPIO2_RST_SHIFT_RSTn);
110+
CLOCK_EnableClock(kCLOCK_GateGPIO2);
111+
#endif
112+
113+
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(gpio3))
114+
RESET_ReleasePeripheralReset(kGPIO3_RST_SHIFT_RSTn);
115+
CLOCK_EnableClock(kCLOCK_GateGPIO3);
116+
#endif
117+
118+
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(gpio4))
119+
RESET_ReleasePeripheralReset(kGPIO4_RST_SHIFT_RSTn);
120+
CLOCK_EnableClock(kCLOCK_GateGPIO4);
121+
#endif
122+
123+
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(lpuart0))
124+
CLOCK_SetClockDiv(kCLOCK_DivLPUART0, 1u);
125+
CLOCK_AttachClk(kFRO_LF_DIV_to_LPUART0);
126+
RESET_PeripheralReset(kLPUART0_RST_SHIFT_RSTn);
127+
#endif
128+
129+
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(lpuart1))
130+
CLOCK_SetClockDiv(kCLOCK_DivLPUART1, 1u);
131+
CLOCK_AttachClk(kFRO_LF_DIV_to_LPUART1);
132+
RESET_PeripheralReset(kLPUART1_RST_SHIFT_RSTn);
133+
#endif
134+
135+
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(lpuart2))
136+
CLOCK_SetClockDiv(kCLOCK_DivLPUART2, 1u);
137+
CLOCK_AttachClk(kFRO_LF_DIV_to_LPUART2);
138+
RESET_PeripheralReset(kLPUART2_RST_SHIFT_RSTn);
139+
#endif
140+
141+
/* Set SystemCoreClock variable. */
142+
SystemCoreClock = CLOCK_INIT_CORE_CLOCK;
143+
}

boards/nxp/frdm_mcxa166/board.cmake

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#
2+
# Copyright 2025 NXP
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
7+
board_runner_args(jlink "--device=MCXA166")
8+
board_runner_args(linkserver "--device=MCXA166:FRDM-MCXA166")
9+
board_runner_args(pyocd "--target=mcxA166")
10+
11+
include(${ZEPHYR_BASE}/boards/common/linkserver.board.cmake)
12+
include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake)
13+
include(${ZEPHYR_BASE}/boards/common/pyocd.board.cmake)

boards/nxp/frdm_mcxa166/board.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
board:
2+
name: frdm_mcxa166
3+
full_name: FRDM-MCXA166
4+
vendor: nxp
5+
socs:
6+
- name: mcxa166
32.7 KB
Binary file not shown.

boards/nxp/frdm_mcxa166/doc/index.rst

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
.. zephyr:board:: frdm_mcxa166
2+
3+
Overview
4+
********
5+
6+
FRDM-MCXA166 are compact and scalable development boards for rapid prototyping of
7+
MCX A16X MCUs. They offer industry standard headers for easy access to the MCUs I/Os,
8+
integrated open-standard serial interfaces and an on-board MCU-Link debugger.
9+
MCX A Series are high-performance, low-power microcontrollers with MAU,SmartDMA and performance efficiency.
10+
11+
Hardware
12+
********
13+
14+
- MCX-A166 Arm Cortex-M33 microcontroller running at 180 MHz
15+
- 1MB dual-bank on chip Flash
16+
- 256 KB RAM
17+
- 1x FlexCAN with FD, 1x RGB LED, 3x SW buttons
18+
- On-board MCU-Link debugger with CMSIS-DAP
19+
- Arduino Header, SmartDMA/Camera Header, mikroBUS
20+
21+
For more information about the MCX-A166 SoC and FRDM-MCXA166 board, see:
22+
23+
- `MCX-A166 SoC Website`_
24+
- `MCX-A166 Datasheet`_
25+
- `MCX-A166 Reference Manual`_
26+
- `FRDM-MCXA166 Website`_
27+
- `FRDM-MCXA166 User Guide`_
28+
- `FRDM-MCXA166 Board User Manual`_
29+
- `FRDM-MCXA166 Schematics`_
30+
31+
Supported Features
32+
==================
33+
34+
.. zephyr:board-supported-hw::
35+
36+
Connections and IOs
37+
===================
38+
39+
The MCX-A166 SoC has 6 gpio controllers and has pinmux registers which
40+
can be used to configure the functionality of a pin.
41+
42+
+------------+-----------------+----------------------------+
43+
| Name | Function | Usage |
44+
+============+=================+============================+
45+
| PIO2_3 | UART | UART RX |
46+
+------------+-----------------+----------------------------+
47+
| PIO2_2 | UART | UART TX |
48+
+------------+-----------------+----------------------------+
49+
50+
System Clock
51+
============
52+
53+
The MCX-A166 SoC is configured to use FRO running at 180MHz as a source for
54+
the system clock.
55+
56+
Serial Port
57+
===========
58+
59+
The FRDM-MCXA166 SoC has 6 LPUART interfaces for serial communication.
60+
LPUART 2 is configured as UART for the console.
61+
62+
Programming and Debugging
63+
*************************
64+
65+
Build and flash applications as usual (see :ref:`build_an_application` and
66+
:ref:`application_run` for more details).
67+
68+
Configuring a Debug Probe
69+
=========================
70+
71+
A debug probe is used for both flashing and debugging the board. This board is
72+
configured by default to use the MCU-Link CMSIS-DAP Onboard Debug Probe.
73+
74+
Using LinkServer
75+
----------------
76+
77+
Linkserver is the default runner for this board, and supports the factory
78+
default MCU-Link firmware. Follow the instructions in
79+
:ref:`mcu-link-cmsis-onboard-debug-probe` to reprogram the default MCU-Link
80+
firmware. This only needs to be done if the default onboard debug circuit
81+
firmware was changed. To put the board in ``ISP mode`` to program the firmware,
82+
short jumper JP4.
83+
84+
Using J-Link
85+
------------
86+
87+
There are two options. The onboard debug circuit can be updated with Segger
88+
J-Link firmware by following the instructions in
89+
:ref:`mcu-link-jlink-onboard-debug-probe`.
90+
To be able to program the firmware, you need to put the board in ``ISP mode``
91+
by shortening the jumper JP4.
92+
The second option is to attach a :ref:`jlink-external-debug-probe` to the
93+
10-pin SWD connector (J14) of the board. Additionally, the jumper JP6 must
94+
be shorted.
95+
For both options use the ``-r jlink`` option with west to use the jlink runner.
96+
97+
.. code-block:: console
98+
99+
west flash -r jlink
100+
101+
Configuring a Console
102+
=====================
103+
104+
Connect a USB cable from your PC to J15, and use the serial terminal of your choice
105+
(minicom, putty, etc.) with the following settings:
106+
107+
- Speed: 115200
108+
- Data: 8 bits
109+
- Parity: None
110+
- Stop bits: 1
111+
112+
Flashing
113+
========
114+
115+
Here is an example for the :zephyr:code-sample:`hello_world` application.
116+
117+
.. zephyr-app-commands::
118+
:zephyr-app: samples/hello_world
119+
:board: frdm_mcxa166
120+
:goals: flash
121+
122+
Open a serial terminal, reset the board (press the RESET button), and you should
123+
see the following message in the terminal:
124+
125+
.. code-block:: console
126+
127+
*** Booting Zephyr OS build v3.6.0-4478-ge6c3a42f5f52 ***
128+
Hello World! frdm_mcxa166/mcxa166
129+
130+
Debugging
131+
=========
132+
133+
Here is an example for the :zephyr:code-sample:`hello_world` application.
134+
135+
.. zephyr-app-commands::
136+
:zephyr-app: samples/hello_world
137+
:board: frdm_mcxa166/mcxa166
138+
:goals: debug
139+
140+
Open a serial terminal, step through the application in your debugger, and you
141+
should see the following message in the terminal:
142+
143+
.. code-block:: console
144+
145+
*** Booting Zephyr OS build v3.6.0-4478-ge6c3a42f5f52 ***
146+
Hello World! frdm_mcxa166/mcxa166
147+
148+
Troubleshooting
149+
===============
150+
151+
.. include:: ../../common/segger-ecc-systemview.rst
152+
:start-after: segger-ecc-systemview
153+
154+
.. include:: ../../common/board-footer.rst
155+
:start-after: nxp-board-footer
156+
157+
.. _MCX-A166 SoC Website:
158+
https://www.nxp.com/products/processors-and-microcontrollers/arm-microcontrollers/general-purpose-mcus/mcx-arm-cortex-m/mcx-a-series-microcontrollers/mcx-a13x-14x-15x-mcus-with-arm-cortex-m33-scalable-device-options-low-power-and-intelligent-peripherals:MCX-A13X-A14X-A15X
159+
160+
.. _MCX-A166 Datasheet:
161+
https://www.nxp.com/docs/en/data-sheet/MCXAP100M96FS6.pdf
162+
163+
.. _MCX-A166 Reference Manual:
164+
https://www.nxp.com/webapp/Download?colCode=MCXAP100M96FS6RM
165+
166+
.. _FRDM-MCXA166 Website:
167+
https://www.nxp.com/design/design-center/development-boards-and-designs/general-purpose-mcus/frdm-development-board-for-mcx-a144-5-6-a154-5-6-mcus:FRDM-MCXA166
168+
169+
.. _FRDM-MCXA166 User Guide:
170+
https://www.nxp.com/document/guide/getting-started-with-frdm-mcxa166:GS-FRDM-MCXA166
171+
172+
.. _FRDM-MCXA166 Board User Manual:
173+
https://www.nxp.com/docs/en/user-manual/UM12121.pdf
174+
175+
.. _FRDM-MCXA166 Schematics:
176+
https://www.nxp.com/webapp/Download?colCode=SPF-90841
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright 2025 NXP
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
7+
#include <nxp/mcx/MCXA166VLQ-pinctrl.h>
8+
9+
&pinctrl {
10+
pinmux_lpuart2: pinmux_lpuart2 {
11+
group0 {
12+
pinmux = <LPUART2_RXD_P2_3>,
13+
<LPUART2_TXD_P2_2>;
14+
drive-strength = "low";
15+
slew-rate = "fast";
16+
input-enable;
17+
};
18+
};
19+
20+
};

0 commit comments

Comments
 (0)