UART0 API functions in KSDK v2.0

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

UART0 API functions in KSDK v2.0

969 Views
danieltruong
Contributor IV

Hi,

 

I'm just wondering how one can use API function to initialize the UART0 channel in Kinetis micro such as UART_Init() in the "fsl_uart.c" driver in KSDK v2.0 ?

It is obvious that this function UART_Init() is designed for UART1 & UART2 because of the structure type is different (UART_Type) from UART0 (UART0_Type).

 

Here's the function prototype:

status_t UART_Init(UART_Type *base, const uart_config_t *config, uint32_t srcClock_Hz);

 

I couldn't find anything equivalent for UART0 in the said driver. Could someone please help me some advice?

 

Thanks,

Daniel

Labels (1)
5 Replies

619 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Daniel

The API UART_Init is applied to all UART0, UART1, UART2.

I would suggest you check the following macros when you init UART0,   you need to modify them according to your project

<board.h>


#define BOARD_DEBUG_UART_TYPE DEBUG_CONSOLE_DEVICE_TYPE_LPSCI
#define BOARD_DEBUG_UART_BASEADDR (uint32_t) UART0
#define BOARD_DEBUG_UART_CLKSRC kCLOCK_CoreSysClk
#define BOARD_DEBUG_UART_CLK_FREQ CLOCK_GetCoreSysClkFreq()

Regards

Chen

0 Kudos
Reply

619 Views
danieltruong
Contributor IV

Hi Daniel,

Just adding to my comment above to give you some background info. I'm not using FRDM-KL26Z board at this stage anymore. I'm switching to my real board which uses the MKL26Z256VLL4 micro. So UART0 is being used as normal channel to connect to a peripheral device, NOT used as debug channel via OpenSDA as seen in most FRDM- board. With this condition, should I do something (define some macro?) to make UART0 available for "normal mode", as opposed to "debug" mode? I guess all of these questions should be answered if NXP could provide us some example codes for the case of UART0.

Thanks,

Daniel

0 Kudos
Reply

619 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Daniel

Thanks for your additional information. For KL26, UART0 is different than UART1 and UART2. Please check the following code for initialize uart0

            lpsci_config_t lpsci_config;
          ...
            LPSCI_GetDefaultConfig(&lpsci_config);
            lpsci_config.baudRate_Bps = baudRate;
            /* Enable clock and initial UART module follow user configure structure. */
            LPSCI_Init();
            LPSCI_EnableTx();
            LPSCI_EnableRx();

You can refer to the fsl_debug_console.c for more information. 

(see case DEBUG_CONSOLE_DEVICE_TYPE_LPSCI:)

Regards

Daniel

619 Views
danieltruong
Contributor IV

Thank you Daniel C. Your input really helps to open the door for me to solve my problem. With something as basic as this, I wish NXP provided it with some kind of KSDK 2.0 reference manual for the users. Instead, we just don't know the info until we ask around to find out.

Anyway I really appreciate your help.

Have a nice day!

-Daniel T.

0 Kudos
Reply

619 Views
danieltruong
Contributor IV

Hi Daniel,

Thanks for providing the clues. However, could you elaborate in a little more details as to how I can use these macros to initialize UART0 using UART_Init() function? The best way is perhaps you could upload some example codes to guide me through if you can. Of all the demo examples given by NXP, I could only find UART1 examples but not single one that demonstrates UART0.

Thanks,

Daniel T.

0 Kudos
Reply