KE02 and KL02 micro to micro UART communication issues, help needed

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

KE02 and KL02 micro to micro UART communication issues, help needed

Jump to solution
2,105 Views
umsankarkalluru
Contributor III

I am using MKE02Z64VLD2 and MKL02Z32VFM4 micros on the same board, and they are communicating using UART null modem (Just Tx and Rx are connected).

I am transmitting 6 bytes of data from KL02 to KE02, The below is array of data i am sending for different 18 events which will occur on KL02

{0x00, 0x01, 0x00, 0x01, 0x00, 0x01},
{0x00, 0x02, 0x00, 0x02, 0x00, 0x02},
{0x01, 0x00, 0x01, 0x00, 0x01, 0x00},
{0x02, 0x00, 0x02, 0x00, 0x02, 0x00},
{0x01, 0x04, 0x01, 0x00, 0x01, 0x00},
{0x01, 0x04, 0x00, 0x01, 0x00, 0x01},
{0x01, 0x04, 0x01, 0x02, 0x03, 0x04},
{0x01, 0x04, 0x01, 0x02, 0x00, 0x00},
{0x01, 0x04, 0x00, 0x00, 0x02, 0x01},
{0x01, 0x04, 0x00, 0x00, 0x00, 0x01},
{0x01, 0x04, 0x02, 0x00, 0x00, 0x00},
{0x01, 0x04, 0x00, 0x02, 0x00, 0x00},
{0x01, 0x04, 0x00, 0x00, 0x02, 0x00},
{0x01, 0x04, 0x00, 0x00, 0x00, 0x02},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x01},
{0x00, 0x00, 0x00, 0x00, 0x02, 0x00},
{0x00, 0x00, 0x00, 0x03, 0x00, 0x00},
{0x00, 0x04, 0x00, 0x00, 0x00, 0x00}

The issue I am facing here is , whenever the data contains two or more 0x00 in the packet the KE02 micro does not receive 6 bytes instead it received 5 bytes and even the received 5 bytes are not correct, I might receive 0x00, 0xC0, 0x00, 0x0E, 0x01. Which were not expected.

I am using interrupt service to send and receive bytes on both micros.

Anyone has faced such issue earlier, please help me.

0 Kudos
1 Solution
1,677 Views
umsankarkalluru
Contributor III

Hi Hui_Ma,

We could solve the issue by using external clock instead of internal clock, which was causing some timing issue.

KL02 internal clock was having tolerance/inaccuracy issues.

In HW for KL02 microcontroller we had to remove crystal capacitors and resistors to make external clock functional

Thanks for your help.

View solution in original post

0 Kudos
14 Replies
1,677 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

It need to check the UART interrupt ISR routine.

If it is possible, could you provide your test code?

We could check if there with software issue. Thanks.


Have a great day,
Ma Hui

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

0 Kudos
1,677 Views
umsankarkalluru
Contributor III

Hi,

Thanks for reply, please find the attached project workspace,

I used KDS 2.00 IDE

0 Kudos
1,677 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

I do a similar test with FRDM-KE02Z board and FRDM-KL02Z board.

2015-06-03_11-20-38.png

I don't meet you mentioned issue.

You could find my test video and I also attached the test code for your reference.

Wish it helps.


Have a great day,
Ma Hui

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

0 Kudos
1,677 Views
umsankarkalluru
Contributor III

Hi Hui_Ma,

Thanks for spending time and providing the feedback on this.

The above experiment you did and code I have provided works communicating from KE02 to KL02, but the actual problem was to communicate from KL02 to KE02.

I repeated the experiment with custom board with KL02 processor and FRDM-KE02Z board and i still face the issue of not communicating properly from KL02 to KE02.

Please find the attached code which will communicate from KL02 to KE02,

Since I don't have KL02 freescale demo board , can you please run the attached firmware on the above setup you have and let me know if you see the correct bytes.

0 Kudos
1,677 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

When you slow down the baud rate, if the problem could be fixed?

best regards,

Ma Hui

0 Kudos
1,677 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

I find similar error with FRDM-KL02Z board.

When using the same routine with FRDM-KE02Z, there will added to send a 0x00 and the following data is also incorrect.

So, I change the transfer way and using below code, I will get the correct data output from FRDM-KL02Z.

Error = AS1_SendBlock(MySerialPtr, OutData, 8U);/* Initialization of AS1 component */

Please try if it works for you.


Have a great day,
Ma Hui

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

0 Kudos
1,677 Views
umsankarkalluru
Contributor III

Can you please specify what did you change?

If baud rate, then what baud rate you are using currently?

Did you change the KL02 code , if so what exactly you changed.

Meanwhile I will try to reduce the baud and check here.

Thanks,

0 Kudos
1,677 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Please check attached KL02 code, which I change the code and also the baud rate to 57600.

Wish it helps.


Have a great day,
Ma Hui

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

0 Kudos
1,678 Views
umsankarkalluru
Contributor III

Hi Hui_Ma,

We could solve the issue by using external clock instead of internal clock, which was causing some timing issue.

KL02 internal clock was having tolerance/inaccuracy issues.

In HW for KL02 microcontroller we had to remove crystal capacitors and resistors to make external clock functional

Thanks for your help.

0 Kudos
1,677 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Thank you for the info.

When customer want to use KL02 internal clock, it need to be trimmed firstly.

During my test, I also using the external 32KHz clock source of FRDM-KL02Z board.


Have a great day,
Ma Hui

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

0 Kudos
1,677 Views
umsankarkalluru
Contributor III

Hi ,

As we know earlier KE02 and KL02 had UART communication issue with internal clock, we are facing the same issue with KE04 part.

Issue:

PC tool is configured for 9600 baud rate and KE04 part is configured close to 8192 and communication works.

But if KE04 is configured close to 9600, say 9500 the communication doesn't work.

Expected:

0x06, 0x07, 0x08, 0x09, 0x10, 0x11, 0x01, 0x04, 0x01, 0x00, 0x01, 0x00, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18

Received:

0x42, 0x88, 0x45, 0x48, 0x41, 0x28, 0x40, 0x20, 0x4B, 0x69, 0x70, 0x4B, 0xFC


And you are saying that "it need to be trimmed firstly", can you please guide me what exactly you meant. Giving SCTRIM value differently and checking will work?

0 Kudos
1,677 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

Please check attached document about how to use P&E Multilink Universal tool to trim the internal ICS clock with CodeWarrior or KDS software.

And below is the software to load trim value to related registers:

  if ( *((uint8_t*) 0x03FFU) != 0xFFU) {

  ICS_C3 = *((uint8_t*) 0x03FFU);

    }

  if ( *((uint8_t*) 0x03FEU) != 0xFFU) {

  ICS_C4 |= *((uint8_t*) 0x03FEU);

    }

Wish it helps.


Have a great day,
Ma Hui

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

0 Kudos
1,677 Views
umsankarkalluru
Contributor III

Hi Hui_Ma,

Thanks for your help. I still see problem when I am sending multiple packers.

Can you please send the below array data

uint8 cmd_to_micro_debug[18][6] = {

  {0x00, 0x01, 0x00, 0x01, 0x00, 0x01},

  {0x00, 0x02, 0x00, 0x02, 0x00, 0x02},

  {0x01, 0x00, 0x01, 0x00, 0x01, 0x00},

  {0x02, 0x00, 0x02, 0x00, 0x02, 0x00},

  {0x01, 0x04, 0x01, 0x00, 0x01, 0x00},

  {0x01, 0x04, 0x00, 0x01, 0x00, 0x01},

  {0x01, 0x04, 0x01, 0x02, 0x03, 0x04},

  {0x01, 0x04, 0x01, 0x02, 0x00, 0x00},

  {0x01, 0x04, 0x00, 0x00, 0x02, 0x01},

  {0x01, 0x04, 0x00, 0x00, 0x00, 0x01},

  {0x01, 0x04, 0x02, 0x00, 0x00, 0x00},

  {0x01, 0x04, 0x00, 0x02, 0x00, 0x00},

  {0x01, 0x04, 0x00, 0x00, 0x02, 0x00},

  {0x01, 0x04, 0x00, 0x00, 0x00, 0x02},

  {0x00, 0x00, 0x00, 0x00, 0x00, 0x01},

  {0x00, 0x00, 0x00, 0x00, 0x02, 0x00},

  {0x00, 0x00, 0x00, 0x03, 0x00, 0x00},

  {0x00, 0x04, 0x00, 0x00, 0x00, 0x00}

};

I was sending the above 18 packets of each 6 bytes on different events (button press), the baud I am using us 4809 which is slower than yours.

The below bold packers are the wrong ones i received.

0x00x10x00x10x00x1
0x00x20x00x20x00x2
0x10x00x10x00x10x0
0x20x00x20x00x20x0
0x10x40x10x00x10x0
0x10x40x00x10x00x1
0x10x40x10x20x30x4
0x10x40x10x20x00x0
0x10x40x00x00x20x1
0x10x40x00x00x00xc0
0x10x40x20x00x00x0
0x10x40x00x20x00x0
0x10x40x00x00x20x0
0x10x40x00x00x00x2
0x00x00x00x00x1
0x00x00x0 0x20x0
0x00x00x00x30x00x0
0x00x40x00x00x00x0

Can you please send the above data in your set up periodically say every 1 Sec.

Thanks you so much for your help

0 Kudos
1,677 Views
umsankarkalluru
Contributor III

Hi Hui_Ma,

Did you try the above data? can you please share your testing results?

0 Kudos