iMX8QM cortex m4 UART instance

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

iMX8QM cortex m4 UART instance

221 次查看
io
Contributor I
Here is board.h definitions I got from sdk example
#if defined(MIMX8QM_CM4_CORE0
#define BOARD_DEBUG_UART_BASEADDR (uint32_t) CM4_0__LPUART
#define BOARD_DEBUG_UART_INSTANCE 0U
#define BOARD_DEBUG_UART_SC_RSRC SC_R_M4_0_UART
#define BOARD_DEBUG_UART_CLKSRC kCLOCK_M4_0_Lpuart
#define BOARD_UART_IRQ M4_0_LPUART_IRQn
#define BOARD_UART_IRQ_HANDLER M4_0_LPUART_IRQHandler
#define BOARD_M4_CPU_RSRC SC_R_M4_0_PID0
#elif defined(MIMX8QM_CM4_CORE1)
#define BOARD_DEBUG_UART_BASEADDR (uint32_t) DMA__LPUART2
#define BOARD_DEBUG_UART_INSTANCE 4U
#define BOARD_DEBUG_UART_SC_RSRC SC_R_UART_2
#define BOARD_DEBUG_UART_CLKSRC kCLOCK_DMA_Lpuart2
#define BOARD_UART_IRQ DMA_UART2_INT_IRQn
#define BOARD_UART_IRQ_HANDLER DMA_UART2_INT_IRQHandler
#define BOARD_M4_CPU_RSRC SC_R_M4_1_PID0
#else
#error "No valid BOARD_DEBUG_UART_BASEADDR defined."
#endif
 
And this is a struct contains uart instance that needed to specify in function DbgConsole_Init()
/*! @brief UART configuration structure. */
typedef struct _hal_uart_config
{
uint32_t srcClock_Hz; /*!< Source clock */
uint32_t baudRate_Bps; /*!< Baud rate */
hal_uart_parity_mode_t parityMode; /*!< Parity mode, disabled (default), even, odd */
hal_uart_stop_bit_count_t stopBitCount; /*!< Number of stop bits, 1 stop bit (default) or 2 stop bits */
uint8_t enableRx; /*!< Enable RX */
uint8_t enableTx; /*!< Enable TX */
uint8_t enableRxRTS; /*!< Enable RX RTS */
uint8_t enableTxCTS; /*!< Enable TX CTS */
uint8_t instance; /*!< Instance (0 - UART0, 1 - UART1, ...), detail information please refer to the
SOC corresponding RM.
Invalid instance value will cause initialization failure. */
#if (defined(UART_ADAPTER_NON_BLOCKING_MODE) && (UART_ADAPTER_NON_BLOCKING_MODE > 0U))
hal_uart_block_mode_t mode; /*!< Uart block mode */
#endif /* UART_ADAPTER_NON_BLOCKING_MODE */
#if (defined(HAL_UART_ADAPTER_FIFO) && (HAL_UART_ADAPTER_FIFO > 0u))
uint8_t txFifoWatermark;
uint8_t rxFifoWatermark;
#endif
} hal_uart_config_t;

Could you explain me what is uart instance? Where can I find information about uart instance? I know the comments said its in SoC Ref. Manual but I still can't figure out which one?
标记 (4)
0 项奖励
回复
2 回复数

192 次查看
Chavira
NXP TechSupport
NXP TechSupport

Hi @io!


In the context of embedded systems and SDKs like the one you're using, a UART instance refers to a specific UART peripheral available on your SoC (System on Chip). Most modern SoCs have multiple UARTs (e.g., UART0, UART1, UART2, etc.), and each one is assigned an instance number.

 

or your case, since you're working with the NXP i.MX8QM, here’s how to locate the UART instance:

Open the i.MX8QM Reference Manual.


Search for LPUART or UART in the document.
Look for a section like Peripheral Memory Map or UART Overview.
Each UART peripheral (e.g., LPUART0, LPUART1, etc.) will be listed with:
Its base address
Its instance number
Its interrupt vector
Its clock source

Best Regards,

Chvaira

0 项奖励
回复

149 次查看
io
Contributor I

Hi @Chavira

Thanks for your response.

My original problem was that I wanted to switch the debug console UART on Cortex-M4 core 0 to another UART, because the default pin (M40_UART) used in the SDK hello_world example is already in use by another core on my board. That’s why I needed to understand what the instance field in hal_uart_config_t really meant. In DbgConsole_Init() I need to pass that value.

After checking some files related to that function. in MIMX8QM6_cm4_core0.h I found the definitions of the uart base address.

/** Array initializer of LPUART peripheral base addresses */
#define LPUART_BASE_ADDRS { CM4_0__LPUART_BASE, CM4_1__LPUART_BASE, DMA__LPUART0_BASE, DMA__LPUART1_BASE, DMA__LPUART2_BASE, DMA__LPUART3_BASE, DMA__LPUART4_BASE, SCU__LPUART_BASE }
/** Array initializer of LPUART peripheral base pointers */
#define LPUART_BASE_PTRS { CM4_0__LPUART, CM4_1__LPUART, DMA__LPUART0, DMA__LPUART1, DMA__LPUART2, DMA__LPUART3, DMA__LPUART4, SCU__LPUART }  

So the instance field is just the index into this array of base addresses (?). It works anyway. Thanks

Best Regards,

io

0 项奖励
回复