FRDM K64F UART communication using MCU xpresso

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

FRDM K64F UART communication using MCU xpresso

5,176 Views
trialaccount12
Contributor V

Hi, I started to work on FRDM k64F using MCU xpresso. I want my frdm board to receive input data through its UART port, any UART port. I went through the examples given in MCU for UART communication like polling, edma transfer, and few methods.

But was not able to figure out which would be an efficient and easy way of receiving data. The data I want to receive as an input to my board looks like this

" Temperature value is %d"  for every minute.

I have worked on frdm boards with mbed compiler but quite confused with MCU expresso.

Any pointers would be highly helpful.

Regards

Niranjan

14 Replies

3,332 Views
trialaccount12
Contributor V

Yeah, will do it. Sure!! Thank you.

regards

Niranjan

3,332 Views
trialaccount12
Contributor V

Hi Alice,

      Yes it did work and I was able to witness the data.

I tried extending the example by sending a message from KW41Z board to K64F.

The message is

Data is being sent

    But the uart_readblocking function is able to read just the first character "D" and print it. It is not receiving all the characters in the message. So I tried initializing a buffer but was not successful in that.

   The (*data) attribute in readblocking function is reading just one byte and not rest of the message.

Any pointers on how to proceed will be helpful! Thank you.

->>These boards operate at different clock frequencies.!

0 Kudos

3,332 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Niranjan ravi,

- Are they the same UART baud rate ?

- I recommend you check step by step,

First use terminal test whether KW41 send all the data ;

Then use terminal send all the same date to K64, use the same baud rate , check whether K64 can

receive all data;

Then connect KW41 with K64 to test .


Have a great day,
TIC

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

3,332 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Niranjan,

I think you can refer to the UART demo of "uart_interrupt" under SDK , open it through Impot SDK example(s)... ->

choose FRDM-K64 board-> choose this demo under "driver_examples".

About the function of this demo , please read about "readme.txt", if have any question about this, you can contact us

without any hesitate.

pastedImage_1.png

Hope it helps,


Have a great day,
TIC

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

3,332 Views
trialaccount12
Contributor V

HI, thank you for your reply. I ran the uart_interupt demo using UART 0. Then I initialized the UART 3 pin (PTC 17 and PTC 16). I tried connecting the Rx (PTC 16) to other board which would send 140 or 100, dummy data. But the data is not being read by the Rx pin. It is always showing as 0.

the initialization I did was:

void BOARD_InitPins(void)
{
/* Port B Clock Gate Control: Clock enabled */
CLOCK_EnableClock(kCLOCK_PortB);
/* Port C Clock Gate Control: Clock enabled */
CLOCK_EnableClock(kCLOCK_PortC);

/* PORTB16 (pin 62) is configured as UART0_RX */
PORT_SetPinMux(BOARD_INITPINS_DEBUG_UART_RX_PORT, BOARD_INITPINS_DEBUG_UART_RX_PIN, kPORT_MuxAlt3);

/* PORTB17 (pin 63) is configured as UART0_TX */
PORT_SetPinMux(BOARD_INITPINS_DEBUG_UART_TX_PORT, BOARD_INITPINS_DEBUG_UART_TX_PIN, kPORT_MuxAlt3);

/* PORTC16 (pin 90) is configured as UART3_RX */
PORT_SetPinMux(BOARD_INITPINS_TMR_1588_0_PORT, BOARD_INITPINS_TMR_1588_0_PIN, kPORT_MuxAlt3);

/* PORTC17 (pin 91) is configured as UART3_TX */
PORT_SetPinMux(BOARD_INITPINS_TMR_1588_1_PORT, BOARD_INITPINS_TMR_1588_1_PIN, kPORT_MuxAlt3);

SIM->SOPT5 = ((SIM->SOPT5 &
/* Mask bits to zero which are setting */
(~(SIM_SOPT5_UART0TXSRC_MASK)))

/* UART 0 transmit data source select: UART0_TX pin. */
| SIM_SOPT5_UART0TXSRC(SOPT5_UART0TXSRC_UART_TX));
}

Then in uart_interrupt.c 


#define DEMO_UART UART0
#define DEMO_UART_CLKSRC UART0_CLK_SRC
#define DEMO_UART_CLK_FREQ CLOCK_GetFreq(UART0_CLK_SRC)
#define DEMO_UART_IRQn UART0_RX_TX_IRQn
#define DEMO_UART_IRQHandler UART0_RX_TX_IRQHandler

But the void DEMO_UART_IRQHandler(void) is not able to read the value.

The data variable is always reading 0 whereas it should read the received inputs.  Can you please tell me where I went wrong? I am not able to figure it out?

Regards

Niranjan

3,332 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

   Hello Niranjan,

Please also change the UART0 to UART3, then have a try, first  try the function just like the  "uart_interupt demo:,

if still can't work , please share your project.

pastedImage_1.png


Have a great day,
TIC

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

3,332 Views
trialaccount12
Contributor V

Yes, hi. I changed it to UART 3 and only I tried.

My bad, I did not update it in a way in my comment. 

I could not find the option to add an attachment here.  I have attached the entire project in the below link.

  https://drive.google.com/open?id=1et-EKxImAFkDeN60ZJ4KlWTFSmJI1NZI   

The mbed code fro which I am sending data to this FRDM board is 

#include "mbed.h"
Serial pc(USBTX, USBRX);
Serial uart(D1, D0);
int main()
{
const uint8_t number = 5;
while(1)
{
wait(2);
uart.putc(number);
} }

The function:

void DEMO_UART_IRQHandler(void) which has a variable called data  is supposed to read the incoming values. It is just returning 0. 

I am not sure where I am going wrong in the above project. Any help would be highly helpful.

Thanks and Regards

Niranjan

3,332 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Niranjan,

First please use a serial terminal on PC to check whether your mbed board send data correctly ,

or oscilloscope .

Sorry we can't enter into google drive,  we have limitation for it . Please attach your project as below :

click "Actions" button -> Edit -> Attach:

pastedImage_2.png

pastedImage_1.png


Have a great day,
TIC

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

3,332 Views
trialaccount12
Contributor V

Hi Alice,

           I have uploaded the project in the original question as a  frdmk64f_uart_interrupt.zip folder.  

Yes, I have tried serial terminal with pc. The code for sending data '53':

#include "mbed.h"
Serial pc(USBTX, USBRX);
Serial uart(D1, D0);
int main()
{
uint8_t number = 53;
while(1)
{
wait(2);
printf("%u\n\r",number);
uart.putc(number);
} }

I used serial port with a different k64F and I am receiving '53' on the receiver side. But when I run it through MCU , i am not getting output.

Please let me know how to proceed.

Thanks and regards

Niranjan

3,332 Views
converse
Senior Contributor V

So you are trying to output a character with the ascii value of 53 (decimal). This is the character ‘5’. Is that what you want to do?

3,332 Views
trialaccount12
Contributor V

No.I quoted '53' and '5' just as an example. The aim is to send a value from a board to another board and receive it.  The problem i am facing I am not receiving any values in my board.

Regards

Niranjan

3,332 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Niranjan,

I test your project on my side  FRDM-K64 board, UART can work well , no matter send or receive function:

pastedImage_1.png

So pleas check your hardware, on FRDM-K64,  PTC16 is J1-2, PTC17 is J1-4:

pastedImage_2.png


Have a great day,
TIC

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

3,332 Views
trialaccount12
Contributor V

Thanks for the heads-up.

Strange! This did not work in my pc. I would go ahead and try in a different pc.

It was very helpful.

Regards

Niranjan

3,332 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

OK , also check whether choose the correct serial port on your terminal of PC , not the OpenSDA (UART 0) .