UART0 issue with TWR-K65F180 and TWR-SER2 boards

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

UART0 issue with TWR-K65F180 and TWR-SER2 boards

Jump to solution
1,820 Views
mmoncigoli
Contributor III

Hello community, this is my first post here. Please, I am asking help because I’m having big issues with K65 UART :smileysad::smileysad::smileysad:

I am using TWR-K65F180M tower board and simply want to make K65 MCU communicate - over UART0->USB - with Tera Term PC-console (I want to visualize an initial string, enter a single character from the console and echo it back to the console itself). The issue I’m having is that I cannot communicate over UART0. In fact, I checked with the scope if the TWR-K65F180M board transmits and receives data over UART0, but I always see a constant 3.3V signal. No data is both transmitted and received! I can do it just over UART2 and openSDA USB port, but I cannot use this port for my final goal (which is to make this board communicate with another device over UART. In addition, I cannot use the RS-232 present in the TWR-SER2 board because, in this case, I should renounce in using openSDA USB port for debugging of TWR-K65F180M board).

I want to use “serial-to-USB” port of TWR-SER2 board (connected to TWR-K65F180M through the elevator board). Looking at the schematics, in order to use the serial-to-USB hardware converter, I have to use UART0 MCU port (connected over A41 and A42 primary elevator pins).

In order to init and communicate over UART0, I am using Kinetis SDK v.1.3 UART API functions. Following a chunk of code I’m using to initialize, trasmit and receive data over UART0:

/***********************************************************/

#include <string.h>

#include <stdio.h>

#include "board.h"

#includefsl_uart_driver.h"

#include "fsl_clock_manager.h"

// variables declaration

uint8_t rx_char = 0;

uart_state_t uartState0;

uart_user_config_t uartConfig =

{

               .bitCountPerChar = kUart8BitsPerChar,

               .parityMode      = kUartParityDisabled,

               .stopBitCount    = kUartOneStopBit,

.baudRate        = 115200

};

const uint8_t buff_header_1[] = "\r\nK65-UART0 test\r\n ";

int8_t status = FAIL;

memset(&uartState0, 0, sizeof(uart_state_t));

// configure PTA1 (UART0_RX) and PTA2 (UART_TX) pins

PORT_HAL_SetMuxMode(PORTA,1u,kPortMuxAlt3);

PORT_HAL_SetMuxMode(PORTA,2u,kPortMuxAlt3);

// init UART0

UART_DRV_Init(UART0_IDX, uartState, &uartConfig);

// TX a string to the PC-console

UART_DRV_SendDataBlocking(UART0_IDX, buff_header_1, sizeof(buff_header_1), 1000u);

for(;;)

{

               if (kStatus_UART_Success == UART_DRV_ReceiveDataBlocking(UART0_IDX, rx_char, 1u, OSA_WAIT_FOREVER))

               {

            // SUCCESS: echo the character received back to the console

             UART_DRV_SendDataBlocking(UART0_IDX, rx_char, 1u, 1000u);

}

else

{

            // FAIL: do other things

}

}

  /***********************************************************/

I started developing with Freescale products just 2 months ago. But my feeling is that, the issue I’m having, is due to the firmware reported above. There is something wrong, but I cannot understand what.

Anyone can please provide me a help?

  Thanks so much!!!

0 Kudos
1 Solution
1,032 Views
mmoncigoli
Contributor III

Hello Alice,

Many thanks again for your reply. So, at the end, I figured out where the issue was. It was due to the bad UART0 pin configuration I was using in my code. That is, instead of this:

...

// configure PTA1 (UART0_RX) and PTA2 (UART_TX) pins

PORT_HAL_SetMuxMode(PORTA,1u,kPortMuxAlt3);

PORT_HAL_SetMuxMode(PORTA,2u,kPortMuxAlt3);

...

I had to use this:

...

// configure PTA1 (UART0_RX) and PTA2 (UART_TX) pins

PORT_HAL_SetMuxMode(PORTA,1u,kPortMuxAlt2);

PORT_HAL_SetMuxMode(PORTA,2u,kPortMuxAlt2);

...

I realized just today that UART0 pins (PTA1 and PTA2) are on Alt2 and NOT Alt3 as I was writing in PORT_HAL_SetMuxMode(..) functions above.

You can download the CDC serial-to-USB driver for TWR-SER2 board from this link:

http://www.nxp.com/products/software-and-tools/hardware-development-tools/tower-development-boards/p...

The unfortunate thing I noticed, is that TWR-SER2 J5 (serial-to-USB) port is quite unstable. That's the reason I don't use it for the communication but just for the debug.

At this point I've decided to use TWR-SER2 J5 (serial-to-USB) to communicate with the other device I have to connect. And TWR-SER2 J14 (RS-232) to debug my code. In fact, I cannot use TWR-K65 openSDA mini-USB port for debugging, because it is shared with TWR-SER2 J14.

Alice, a question please: in order to have TWR-SER2 J14 (RS-232) as debugging interface (in place of TWR-K65 openSDA mini-USB port), since they both use UART2, I don't have to change anything in my code, right?

Many thanks again for your help

Marco

View solution in original post

0 Kudos
11 Replies
1,033 Views
mmoncigoli
Contributor III

Hello Alice,

Many thanks again for your reply. So, at the end, I figured out where the issue was. It was due to the bad UART0 pin configuration I was using in my code. That is, instead of this:

...

// configure PTA1 (UART0_RX) and PTA2 (UART_TX) pins

PORT_HAL_SetMuxMode(PORTA,1u,kPortMuxAlt3);

PORT_HAL_SetMuxMode(PORTA,2u,kPortMuxAlt3);

...

I had to use this:

...

// configure PTA1 (UART0_RX) and PTA2 (UART_TX) pins

PORT_HAL_SetMuxMode(PORTA,1u,kPortMuxAlt2);

PORT_HAL_SetMuxMode(PORTA,2u,kPortMuxAlt2);

...

I realized just today that UART0 pins (PTA1 and PTA2) are on Alt2 and NOT Alt3 as I was writing in PORT_HAL_SetMuxMode(..) functions above.

You can download the CDC serial-to-USB driver for TWR-SER2 board from this link:

http://www.nxp.com/products/software-and-tools/hardware-development-tools/tower-development-boards/p...

The unfortunate thing I noticed, is that TWR-SER2 J5 (serial-to-USB) port is quite unstable. That's the reason I don't use it for the communication but just for the debug.

At this point I've decided to use TWR-SER2 J5 (serial-to-USB) to communicate with the other device I have to connect. And TWR-SER2 J14 (RS-232) to debug my code. In fact, I cannot use TWR-K65 openSDA mini-USB port for debugging, because it is shared with TWR-SER2 J14.

Alice, a question please: in order to have TWR-SER2 J14 (RS-232) as debugging interface (in place of TWR-K65 openSDA mini-USB port), since they both use UART2, I don't have to change anything in my code, right?

Many thanks again for your help

Marco

0 Kudos
1,032 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Marco,

I also just work out it , so come here to tell you , and see you also solved it , congratulation to you !

About the last question , yes, you don't need change any code , only need set the jumper  on twr-k65 board :

J33 :  1-2

J34 :  1-2

Hope it helps

Alice

0 Kudos
1,032 Views
santiago_gonzal
NXP Employee
NXP Employee

Hello,

You don't need to do that if you just want to have a "Serial-to-USB".

The easiest way is to use the "Hello World example" included in KSDK 1.3. It will configure the uart connected to the OpenSDA (Which is the small chip close to the USB connector) and then this chip will take care of the conversion from the K65 UART to a USB so you can see the printf messages on a terminal.

You can find this example in: C:\Freescale\KSDK_1.3.0\examples\twrk65f180m\demo_apps\hello_world

Regards,


Santiago

0 Kudos
1,032 Views
mmoncigoli
Contributor III

Alice, Santiago, really thanks for your replies!

There is a misunderstanding due to my lack of information of my initial post. I'm really sorry about that.

My final goal is to make the TWR-K65 board MCU to communicate over UART to an external device. Now, JUST in order to debug my code, I replace this external device with a PC-console (so I don't add further complexity). And I want the communication to be over serial-to-USB port of TWR-SER2 board (so that, in the TWR-K65 MCU, I must use UART0). In that way, once my code will work fine, I'll know that my UART communication is working and will connect my tower board system to the external device.

But, what I missed in my initial post, sorry, is that when these two devices will communicate over the UART just described, the user will have to interact with the system using a PC-console. This console will use openSDA USB port (of TWR-K65 board)), that is UART2 port of the MCU. This openSDA port is actually the one used in the "Hello world" example Santiago mentioned.

For this reason, Alice and Santiago, I want to be able to open a communication to the PC-console - now for debugging - using serial-to-USB port of TWR-SER2 (and UART0 of TWR-K65 MCU).

Hope to have been more clear. Sorry again for the confusion.

Any help would be higly appreciated.

Thanks so much

Marco

0 Kudos
1,032 Views
santiago_gonzal
NXP Employee
NXP Employee

Ok, now I understand. So you only need to use the example mentioned adding support for another UART. Follow the steps done in the code to initialice and use the driver and you should be OK.

Regards,

Santiago

0 Kudos
1,032 Views
mmoncigoli
Contributor III

Thanks a lot for your reply Santiago. In the code posted in my initial post above, I actually did it. That initialization code, in the KSDK example, was written for UART2 in the "uart blocking code example". Inside the hardware_init() function, there was another function call which, actually, initialized UART2.  Inside that board library function there wasn't the option for UART0, but just for UART2 and, if I well remember, UART3-4. But, out of that example, I created the code to initialize UART0 using the same KSDK library functions.

I'm having one doubt about the correct initialization of UART0 of this K65 MCU. On its datasheet I read that UART0 and UART1 have a different clock source than the other UARTs. Could this be the reason of my issue?

After having executed my UART0 init code, on the scope I see that the UART0_TX signal is constant to 3.3V. But, trying to capture the message "square wave" with the scope, I see nothing (just the same constant 3.3V signal).

Does anyone know if UART0 has to be initialized in a different way?

Thanks so much for any help

Marco

0 Kudos
1,032 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello mmoncigoli,

- Are you sure you use the UART0 ? If you use the TWR-K65F TWR-SER demo boards of freescale ,

and not change it , the UART of the TWR-SER use the UART2 also.

- If you sue you use  the UART0, yes , the clock source for UART0 is different from UART2,

and you can use the PE+SDK create one project , the add the uart component, configure it  to

UART0, you can refer to the initialization code :

pastedImage_0.png


Have a great day,
Alice

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
1,032 Views
mmoncigoli
Contributor III

Hello Alice, thanks a lot for your useful reply.

Please help me to clarify if I'm making a mistake in terms of using or not UART0.

Here the schematics of the boards:

TWR-K65F180M

http://cache.nxp.com/files/microcontrollers/hardware_tools/schematics/TWR-K65F180M-SCH.pdf

TWR-SER2

http://cache.nxp.com/files/microcontrollers/hardware_tools/schematics/SCH-26185.pdf?fsrch=1&sr=1&pag...

Looking at the schematics of TWR-K65F180M and TWR-SER2 (here attached) and following the signal-path which leads me to the two serial-to-USB data pins (starting from TWR-K65F180M), I see the following:

(here I take UART0_TX of the K65 MCU, that is pin M9 (PTA2). For UART0_RX is similar).

UART0_TX (PTA2, pin M9) -> A42 (primary elevator connector, page 8) -> now let's switch to TWR-SER2 schematics -> A42 (TXD0, primary elevator connector, page 9) -> UART0_TX -> connect pins 1-2 of J7 (pag. 8) -> SO8JS16_RXD -> USB_DP (of MC9S08JS16C) -> USB_DN_IN (pin 2 of mini USB port)

Considering my analysis UART0 is used. Am I wrong or right?

Thanks so much for the useful help

Marco

0 Kudos
1,032 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Marco,

- Sorry i misunderstand you, on the twr-ser board , yes the J5 port (USB)  is correspond to UART0 ,

i said the UART serial  J14 .

- For the J5, i also have not used , and have you install the driver well , you can check it under the Device Manager:

pastedImage_0.png

if yes , could you tell me where can i download it , for i can not install it well .

- And if you only want test the UART with PC, i think you can also use the J14 on twr-ser2 board , i have test this port,

it can work well .

-I will continue working on the J5 port , and will tell you as i find the method.

Hope it helps

Alice

0 Kudos
933 Views
markgreggory
Contributor II

Anyone have this driver (Win8, Win 10 64bit)?

0 Kudos
1,032 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello ,

The UART of TWR-SER2 is  also UART2, you only need change the Jumper  j33 and j34 :

pastedImage_0.png

If i misunderstand your meaning , please tell me .


Have a great day,
Alice

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos