RT600 setup second USART

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

RT600 setup second USART

ソリューションへジャンプ
2,817件の閲覧回数
lorv
Contributor III

I am trying to setup a second USART on my MIMXRT600.  I started with the SDK polling  example and wanted to add a second USART on Flexcomm2. I setup the clock and attach it to the Flexcomm interface, initialize the USART and send someting, but I receive nothing no signal on the wire.

Here is the code of the main.

 

#include "pin_mux.h"
#include "clock_config.h"
#include "board.h"
#include "fsl_usart.h"
#include "fsl_debug_console.h"
/*******************************************************************************
 * Definitions
 ******************************************************************************/
#define DEBUG_BOOT_USART          USART0
//#define DEBUG_BOOT_USART_CLK_SRC  kCLOCK_Flexcomm0
#define DEBUG_BOOT_USART_CLK_FREQ CLOCK_GetFlexCommClkFreq(0U)

#define SERIAL_BOOT_USART              USART2
#define SERIAL_BOOT_USART_CLK_FREQ CLOCK_GetFlexCommClkFreq(2U)

/*******************************************************************************
 * Prototypes
 ******************************************************************************/

/*******************************************************************************
 * Variables
 ******************************************************************************/

uint8_t txbuff1[]   = "Flexcom1 Test\r\n";
uint8_t txbuff2[]   = "Flexcom2 Test\r\n";
uint8_t rxbuff[20] = {0};

/*******************************************************************************
 * Code
 ******************************************************************************/



/*!
 * @brief Main functioné
 */
int main(void)
{
    uint8_t ch;
    usart_config_t usart0_config;
    usart_config_t usart2_config;

    BOARD_InitBootPins();
    BOARD_InitBootClocks();
    BOARD_InitDebugConsole();
    /*
     * config.baudRate_Bps = 115200U;
     * config.parityMode = kUSART_ParityDisabled;
     * config.stopBitCount = kUSART_OneStopBit;
     * config.loopback = false;
     * config.enableTx = false;
     * config.enableRx = false;
     */
    USART_GetDefaultConfig(&usart0_config);
    usart0_config.baudRate_Bps = BOARD_DEBUG_UART_BAUDRATE;
    usart0_config.enableTx     = true;
    usart0_config.enableRx     = true;
    USART_Init(DEBUG_BOOT_USART, &usart0_config, DEBUG_BOOT_USART_CLK_FREQ);

    /* attach FRG0 clock to FLEXCOMM2 (debug console) */
    CLOCK_SetFRGClock(SERIAL_BOOT_UART_FRG_CLK);
    CLOCK_AttachClk(SERIAL_BOOT_UART_CLK_ATTACH);
    USART_GetDefaultConfig(&usart2_config);
    usart2_config.baudRate_Bps = BOARD_DEBUG_UART_BAUDRATE;
    usart2_config.enableTx     = true;
    usart2_config.enableRx     = true;
    USART_Init(SERIAL_BOOT_USART, &usart2_config, SERIAL_BOOT_USART_CLK_FREQ);

    DbgConsole_Printf("DEBUG_BOOT_USART_CLK_FREQ: %d\n", DEBUG_BOOT_USART_CLK_FREQ);
    DbgConsole_Printf("SERIAL_USART_CLK_FREQ: %d\n", SERIAL_BOOT_USART_CLK_FREQ) ;
    USART_WriteBlocking(DEBUG_BOOT_USART, txbuff1, sizeof(txbuff1) - 1);
    USART_WriteBlocking(SERIAL_BOOT_USART, txbuff2, sizeof(txbuff2) - 1);

    return 0;
}

 

 The ini_pins function:

 

 

void BOARD_InitPins(void)
{

    const uint32_t port0_pin1_config = (/* Pin is configured as FC0_TXD_SCL_MISO_WS */
                                        IOPCTL_PIO_FUNC1 |
                                        /* Disable pull-up / pull-down function */
                                        IOPCTL_PIO_PUPD_DI |
                                        /* Enable pull-down function */
                                        IOPCTL_PIO_PULLDOWN_EN |
                                        /* Disable input buffer function */
                                        IOPCTL_PIO_INBUF_DI |
                                        /* Normal mode */
                                        IOPCTL_PIO_SLEW_RATE_NORMAL |
                                        /* Normal drive */
                                        IOPCTL_PIO_FULLDRIVE_DI |
                                        /* Analog mux is disabled */
                                        IOPCTL_PIO_ANAMUX_DI |
                                        /* Pseudo Output Drain is disabled */
                                        IOPCTL_PIO_PSEDRAIN_DI |
                                        /* Input function is not inverted */
                                        IOPCTL_PIO_INV_DI);
    /* PORT0 PIN1 (coords: G2) is configured as FC0_TXD_SCL_MISO_WS */
    IOPCTL_PinMuxSet(IOPCTL, 0U, 1U, port0_pin1_config);

    const uint32_t port0_pin2_config = (/* Pin is configured as FC0_RXD_SDA_MOSI_DATA */
                                        IOPCTL_PIO_FUNC1 |
                                        /* Disable pull-up / pull-down function */
                                        IOPCTL_PIO_PUPD_DI |
                                        /* Enable pull-down function */
                                        IOPCTL_PIO_PULLDOWN_EN |
                                        /* Enables input buffer function */
                                        IOPCTL_PIO_INBUF_EN |
                                        /* Normal mode */
                                        IOPCTL_PIO_SLEW_RATE_NORMAL |
                                        /* Normal drive */
                                        IOPCTL_PIO_FULLDRIVE_DI |
                                        /* Analog mux is disabled */
                                        IOPCTL_PIO_ANAMUX_DI |
                                        /* Pseudo Output Drain is disabled */
                                        IOPCTL_PIO_PSEDRAIN_DI |
                                        /* Input function is not inverted */
                                        IOPCTL_PIO_INV_DI);
    /* PORT0 PIN2 (coords: G4) is configured as FC0_RXD_SDA_MOSI_DATA */
    IOPCTL_PinMuxSet(IOPCTL, 0U, 2U, port0_pin2_config);

    const uint32_t port0_pin15_config = (/* Pin is configured as FC2_TXD_SCL_MISO_WS */
                                        IOPCTL_PIO_FUNC1 |
                                        /* Disable pull-up / pull-down function */
                                        IOPCTL_PIO_PUPD_DI |
                                        /* Enable pull-down function */
                                        IOPCTL_PIO_PULLDOWN_EN |
                                        /* Disable input buffer function */
                                        IOPCTL_PIO_INBUF_DI |
                                        /* Normal mode */
                                        IOPCTL_PIO_SLEW_RATE_NORMAL |
                                        /* Normal drive */
                                        IOPCTL_PIO_FULLDRIVE_DI |
                                        /* Analog mux is disabled */
                                        IOPCTL_PIO_ANAMUX_DI |
                                        /* Pseudo Output Drain is disabled */
                                        IOPCTL_PIO_PSEDRAIN_DI |
                                        /* Input function is not inverted */
                                        IOPCTL_PIO_INV_DI);
    /* PORT0 PIN15 (coords: G2) is configured as FC2_TXD_SCL_MISO_WS */
    IOPCTL_PinMuxSet(IOPCTL, 0U, 15U, port0_pin15_config);

    const uint32_t port0_pin16_config = (/* Pin is configured as FC2_RXD_SDA_MOSI_DATA */
                                        IOPCTL_PIO_FUNC1 |
                                        /* Disable pull-up / pull-down function */
                                        IOPCTL_PIO_PUPD_DI |
                                        /* Enable pull-down function */
                                        IOPCTL_PIO_PULLDOWN_EN |
                                        /* Enables input buffer function */
                                        IOPCTL_PIO_INBUF_EN |
                                        /* Normal mode */
                                        IOPCTL_PIO_SLEW_RATE_NORMAL |
                                        /* Normal drive */
                                        IOPCTL_PIO_FULLDRIVE_DI |
                                        /* Analog mux is disabled */
                                        IOPCTL_PIO_ANAMUX_DI |
                                        /* Pseudo Output Drain is disabled */
                                        IOPCTL_PIO_PSEDRAIN_DI |
                                        /* Input function is not inverted */
                                        IOPCTL_PIO_INV_DI);
    /* PORT0 PIN16 (coords: G4) is configured as FC2_RXD_SDA_MOSI_DATA */
    IOPCTL_PinMuxSet(IOPCTL, 0U, 16U, port0_pin16_config);
}​

 

the relevant part of board.h:

 

/*! @brief The UART to use for debug messages. */
#define BOARD_DEBUG_UART_TYPE     kSerialPort_Uart
#define BOARD_DEBUG_UART_BASEADDR (uint32_t) USART0
#define BOARD_DEBUG_UART_INSTANCE 0U
#define BOARD_DEBUG_UART_CLK_FREQ CLOCK_GetFlexCommClkFreq(0U)
#define BOARD_DEBUG_UART_FRG_CLK \
    (&(const clock_frg_clk_config_t){0, kCLOCK_FrgPllDiv, 255, 0}) /*!< Select FRG0 mux as frg_pll */
#define BOARD_DEBUG_UART_CLK_ATTACH kFRG_to_FLEXCOMM0
#define BOARD_DEBUG_UART_RST        kFC0_RST_SHIFT_RSTn
#define BOARD_DEBUG_UART_CLKSRC     kCLOCK_Flexcomm0
#define BOARD_UART_IRQ_HANDLER      FLEXCOMM0_IRQHandler
#define BOARD_UART_IRQ              FLEXCOMM0_IRQn

/*! @brief The UART to use for serial boot. */
#define SERIAL_BOOT_UART_TYPE     kSerialPort_Uart
#define SERIAL_BOOT_UART_BASEADDR (uint32_t) USART2
#define SERIAL_BOOT_UART_INSTANCE 2U
#define SERIAL_BOOT_UART_CLK_FREQ CLOCK_GetFlexCommClkFreq(2U)
#define SERIAL_BOOT_UART_FRG_CLK \
    (&(const clock_frg_clk_config_t){2, kCLOCK_FrgPllDiv, 255, 0}) /*!< Select FRG0 mux as frg_pll */
#define SERIAL_BOOT_UART_CLK_ATTACH kFRG_to_FLEXCOMM2
#define SERIAL_BOOT_UART_RST        kFC2_RST_SHIFT_RSTn
#define SERIAL_BOOT_UART_CLKSRC     kCLOCK_Flexcomm2
#define SERIAL_BOOT_UART_IRQ_HANDLER      FLEXCOMM2_IRQHandler
#define SERIAL_BOOT_UART_IRQ              FLEXCOMM2_IRQn

 

 the code compiles and runs on the board, but I only get the output of USART0.

What else do I need in order to run the second USART?

0 件の賞賛
返信
1 解決策
2,466件の閲覧回数
lorv
Contributor III

Hi @Miguel04,

I have tested this again, and it is working now. I have set up the system from scratch again since I have been working on other things in the mean time. I don't know what went wrong the last time, but it is working now.

Thank you for your effort anyway.

Regards, lorv

 

元の投稿で解決策を見る

10 返答(返信)
2,767件の閲覧回数
lorv
Contributor III

Can I expect any help on this from NXP, or am I on my own here?

0 件の賞賛
返信
2,745件の閲覧回数
Miguel04
NXP TechSupport
NXP TechSupport

Hi @lorv 

The initialization looks good, the only thing is that the instance usart2 is not connected to the debugger so the serial terminal will not get any data, please verify the transmision connecting a jumper from TX to RX or use an oscilloscope to plot the signal.

Best Regards, Miguel.

0 件の賞賛
返信
2,626件の閲覧回数
lorv
Contributor III

Hi @Miguel04,

it would be really nice to get some further help on this. Especially since my code seems to be ok.

I really do not understand, why I don't get any signal on the Tx and Rx pinst.

Thanks in advance.

Rregards  lorv

0 件の賞賛
返信
2,613件の閲覧回数
Miguel04
NXP TechSupport
NXP TechSupport

Hi @lorv 

I've been lookin into your problem, if you can share with me your project file it would be help in case there is something missing while I replicate it with the code you posted. Also, if you don't want to share the project here, please open a support case here to continue giving you direct support outside the community.

Best Regards, Miguel.

0 件の賞賛
返信
2,587件の閲覧回数
lorv
Contributor III

Hi @Miguel04 ,

thanks for looking into this further. I don't have a project file since I work with gcc directly but I can attach the whole project for you.

Regards lorv

0 件の賞賛
返信
2,562件の閲覧回数
Miguel04
NXP TechSupport
NXP TechSupport

Thank you @lorv 

I'll let you know as soon as I find something.

Best Regards, Miguel.

0 件の賞賛
返信
2,467件の閲覧回数
lorv
Contributor III

Hi @Miguel04,

I have tested this again, and it is working now. I have set up the system from scratch again since I have been working on other things in the mean time. I don't know what went wrong the last time, but it is working now.

Thank you for your effort anyway.

Regards, lorv

 

2,684件の閲覧回数
lorv
Contributor III

Hi miguel,

by now I have tested a loopback with a jumper on J47 pins 6 and 7 and I try to receive blocking, but I receive nothing. Also with an oscilloscope I do not see anything. The sending function seems to return though.

regards

0 件の賞賛
返信
2,694件の閲覧回数
lorv
Contributor III

Hi Miguel, thanks for your answer.

I try to receiver the signal on J47 pins 6 and 7. This is where the flexcomm2 and therefore uart2 is connected on the board isn't it?

regards

0 件の賞賛
返信
1,627件の閲覧回数
anthony_adan
Contributor I

Hi,

Has this issue been solved ?

0 件の賞賛
返信