Skip to content

Conversation

@anilozrenk
Copy link

Description

Fixes UART clock source selection across legacy MAX32 microcontrollers and updates the Zephyr wrapper to properly support IBRO (7MHz) clock selection.

Changes

PeriphDrivers

  • uart_me10.c (MAX32650) & uart_me14.c (MAX32665/66): Fixed MXC_UART_SetClockSource() to:

    • Validate UART instance before proceeding
    • Enable HIRC8 clock source when using PCLK
    • Correct the inverted usePCLK parameter passed to MXC_UART_RevA_SetClockSource()
    • Enable HIRC8 clock when needed
    • Fix inverted usePCLK parameter
  • uart_me11.c (MAX32660): Simplified MXC_UART_SetClockSource() to return E_NO_ERROR since MAX32660 only supports PCLK (no alternative clock source)

  • uart_reva.c: Improved clock source switching logic:

    • Added baud rate validation against the selected clock source's maximum capability
    • Falls back to 115200 baud if current baud rate exceeds clock limits
    • Improved error handling for MXC_UART_SetFrequency() calls

Zephyr Wrapper

  • wrap_max32_uart.h: Updated Wrap_MXC_UART_SetClockSource() to:
    • Add proper SOC-specific handling for MAX32660 (PCLK only)
    • Enable IBRO and PCLK clock source selection for MAX32650/65/66
    • Call the underlying MXC_UART_SetClockSource() for supported clock sources

Affected Devices

  • MAX32650
  • MAX32660
  • MAX32665/MAX32666

@github-actions github-actions bot added MAX32650 Related to the MAX32650 (ME10) MAX32660 Related to the MAX32660 (ME11) MAX32665 Related to the MAX32665 (ME14) Zephyr MSDK Zephyr related change. labels Dec 23, 2025
@ttmut
Copy link
Contributor

ttmut commented Dec 26, 2025

/clang-format-run

Comment on lines 404 to 406
if (baudRate > PeripheralClock / 8) {
baudRate = 115200;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if we do not fall back to 115200bps? How is the behavior in other parts?

Copy link
Author

@anilozrenk anilozrenk Dec 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At reset, when baud registers set 0, GetFrequency will return peripheralClock/3. And maximum baudrate can be pclk/8. This part should only run at reset. if baudrate set once. It can getFrequecy properly. Eg. in zephyr uart_max32 driver tries to set clock first and then set baudrate, it fails. What do you suggest? @ttmut

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the issue.

Well at least set the baudrate to PeripheralClock / 8 so that it is somewhat consistent with the documentation.

The baud rate generator will automatically be reconfigured to the closest possible baud rate.

@anilozrenk anilozrenk force-pushed the fix-uart-clock-selection branch 3 times, most recently from d508375 to e4ab2e3 Compare December 30, 2025 12:00
Comment on lines 404 to 406
if (baudRate > PeripheralClock / 8) {
baudRate = 115200;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the issue.

Well at least set the baudrate to PeripheralClock / 8 so that it is somewhat consistent with the documentation.

The baud rate generator will automatically be reconfigured to the closest possible baud rate.

Unlock ability to change uart clock to 7MHz internal clock
MAX32650/MAX32665/MAX32666

Signed-off-by: Anil Ozrenk <anil.ozrenk@analog.com>
@anilozrenk anilozrenk force-pushed the fix-uart-clock-selection branch from e4ab2e3 to 74165e3 Compare January 5, 2026 14:24
@anilozrenk anilozrenk requested a review from ttmut January 6, 2026 09:08
@anilozrenk anilozrenk force-pushed the fix-uart-clock-selection branch from 74165e3 to 730f4bd Compare January 6, 2026 09:11
Anil Ozrenk added 2 commits January 7, 2026 09:37
Unlock 7MHz internal clock selection for MAX32650,
MAX32652, MAX32665, MAX32666

Signed-off-by: Anil Ozrenk <anil.ozrenk@analog.com>
Max32660 can only use PCLK

Signed-off-by: Anil Ozrenk <anil.ozrenk@analog.com>
@anilozrenk anilozrenk force-pushed the fix-uart-clock-selection branch from 730f4bd to 9651a45 Compare January 7, 2026 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

MAX32650 Related to the MAX32650 (ME10) MAX32660 Related to the MAX32660 (ME11) MAX32665 Related to the MAX32665 (ME14) Zephyr MSDK Zephyr related change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants