Read uart status register Teensy 4.1

Powersoft

Member
is it posible to read the uart status register and uart data register when programming the teensy 4.1 in the arduino ide.
And where can I find the address of these registers, when posible?
Thanks for any help.
 
Yes, you can read the registers and the like.

See chapter 49 of the reference manual for details on UARTS. Paul has recently uploaded a version of the RM that has some annotations that help
to understand things like which IMXRT pins map to which Teensy pin number...

1724330489724.png

For example this page shows you which uarts are used for which SerialX object.
like LPUART6 is used for Serial1.

The Teensy 4.x header file imxrt.h has defines for the majority of the registers of the T4.x.
It has the defines for LPUART6 like:
C:
#define IMXRT_LPUART6        (*(IMXRT_LPUART_t *)IMXRT_LPUART6_ADDRESS)
// LPUART6 requires CCM_CCGR3_LPUART6
#define LPUART6_VERID            (IMXRT_LPUART6.VERID)
#define LPUART6_PARAM            (IMXRT_LPUART6.PARAM)
#define LPUART6_GLOBAL            (IMXRT_LPUART6.GLOBAL)
#define LPUART6_PINCFG            (IMXRT_LPUART6.PINCFG)
#define LPUART6_BAUD            (IMXRT_LPUART6.BAUD)
#define LPUART6_STAT            (IMXRT_LPUART6.STAT)
#define LPUART6_CTRL            (IMXRT_LPUART6.CTRL)
#define LPUART6_DATA            (IMXRT_LPUART6.DATA)
#define LPUART6_MATCH            (IMXRT_LPUART6.MATCH)
#define LPUART6_MODIR            (IMXRT_LPUART6.MODIR)
#define LPUART6_FIFO            (IMXRT_LPUART6.FIFO)
#define LPUART6_WATER            (IMXRT_LPUART6.WATER)
#define IMXRT_LPUART7        (*(IMXRT_LPUART_t *)IMXRT_LPUART7_ADDRESS)
But I typically don't use most of these defines other than the pointer to the defined structure:
C:
// 49.4.1.1: page 2854
typedef struct {
    const uint32_t VERID;
    const uint32_t PARAM;
    volatile uint32_t GLOBAL;
    volatile uint32_t PINCFG;
    volatile uint32_t BAUD;
    volatile uint32_t STAT;
    volatile uint32_t CTRL;
    volatile uint32_t DATA;
    volatile uint32_t MATCH;
    volatile uint32_t MODIR;
    volatile uint32_t FIFO;
    volatile uint32_t WATER;
} IMXRT_LPUART_t;
The easiest way to understand a lot of this is to look through the source code.
Most of it is contained in the source files HardwareSerial.cpp (and the .h file).
 
Back
Top