Can we configure 2 flexio uarts in MKE18F512

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

Can we configure 2 flexio uarts in MKE18F512

1,283 Views
ad_sabir86
Contributor I

Hi,

I have configured 1 UART following the the application note an12174. Both receiver and transmitter works well. 

But when i  configured 2nd UART it doesn't work.  

Labels (2)
Tags (1)
0 Kudos
5 Replies

1,165 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi  Adnan Sabir,

  Do you need 5 UARTs on your side?

  I checked the MKE18F512, this chip contains one FlexIO, 4 Timers, 4 Shifters, 8 PIns.

UART bus can be supported by using two timers, two shifters and two pins.

  So, this FlexIO should can support two UART.

  I have a question, if two can't work together, do you seperate it, eg Timer 0,1, UART1, Timer 2,3 uart2. Then test it one by one, whether it work or not?

Wish it helps you!

Kerry

 

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

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if y

0 Kudos

1,165 Views
ad_sabir86
Contributor I

Hi Kerry

Thanks for replying.

Yes i need 5 UARTs in my application. 4 Full UARTs and 1 UART-Tx. 

As MKE18F512 gives 3 Hardware UARTs, I make 1 FLEXIO UART using Timer0 and 1, and it works fine.

But using the same setting the second UART didn't works. I only need its TX section. For second UART i use Timer2 and SHIFTER2

Following is the code FXIO1 works well, i use interrupt handler for it.

FXIO2 doesn't works, i use polling method to transmit a byte.

void InitFXIO(void)
{
sp1TxFlg = 0;

FLEXIO_CTRL = 0x00000002; // reset All registers
FLEXIO_CTRL = 0x00000000;

InitFXIO1();
InitFXIO2();
FLEXIO_SHIFTSIEN = 0x00000002;
FLEXIO_CTRL = 0x00000001; // Enable FLEXIO Module
}

/*=======================================================*/
/*=======================================================*/
/* InitFXIO1 */
/* Initialize FLEXIO UART @ 38400 */
/* TIMCMP0[15:8] = (No. of bits per char)*2 - 1 */
/* TIMCMP0[15:8] = (8 * 2) - 1 = 15 = 0x0F */
/* TIMCMP0[ 7:0] = (SRC_CLK/BUAD_RATE)/2 - 1 */
/* TIMCMP0[ 7:0] = (4000000/38400)/2 - 1 = 51 = 0x33 */
/*=======================================================*/
/*=======================================================*/
void InitFXIO1(void)
{
FLEXIO_SHIFTCTL0 = 0x00030102; // Tx Mode, FXIO1, Timer0
FLEXIO_SHIFTCFG0 = 0x00000032;

FLEXIO_TIMCTL0 = 0x01C00101;
FLEXIO_TIMCFG0 = 0x00002222;
FLEXIO_TIMCMP0 = 0x00000F33;


FLEXIO_SHIFTCTL1 = 0x01800001; // Rx Mode, FXIO0, Timer1
FLEXIO_SHIFTCFG1 = 0x00000032;

FLEXIO_TIMCTL1 = 0x00000081;
FLEXIO_TIMCFG1 = 0x02042422;
FLEXIO_TIMCMP1 = 0x00000F33;
}

/*=======================================================*/
/*=======================================================*/
void FLEXIO_IRQHandler(void)
{
ui08  c;

if (1 == sp1TxFlg)
   {
   if (txCnt) {txCnt--; FLEXIO_SHIFTBUF0 = *txPtr++; }
   if (0 == txCnt)
     {
    sp1TxFlg = 0;
    FLEXIO_SHIFTSIEN = 0x00000002;
    }
}
if (FLEXIO_SHIFTSTAT & 0x00000002)        // Rx Section
   {
   c = (ui08)(FLEXIO_SHIFTBUFBYS1 & 0x000000FF); 
   if ('G' == c) dataOk = 1;   // Flag for main routine
   }

}

/*=======================================================*/
/*=======================================================*/
/* InitFXIO2 */
/* Initialize FLEXIO UART @ 9600 */
/* TIMCMP0[15:8] = (No. of bits per char)*2 - 1 */
/* TIMCMP0[15:8] = (8 * 2) - 1 = 15 = 0x0F */
/* TIMCMP0[ 7:0] = (SRC_CLK/BUAD_RATE)/2 - 1 */
/* TIMCMP0[ 7:0] = (4000000/9600)/2 - 1 = 207 = 0xCF */
/*=======================================================*/
/*=======================================================*/
void InitFXIO2(void)
{

FLEXIO_SHIFTCTL2 = 0x02030402; // Tx Mode, FXIO4, Timer2
FLEXIO_SHIFTCFG2 = 0x00000032;

FLEXIO_TIMCTL2 = 0x01C00001;
FLEXIO_TIMCFG2 = 0x00002222;
FLEXIO_TIMCMP2 = 0x00000FCF;


}

/*=======================================================*/
/*=======================================================*/
void OutByte(ui08 c)
{
while (!(FLEXIO_SHIFTSTAT & 0x00000004));
FLEXIO_SHIFTBUF2 = c;
}

0 Kudos

1,165 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Adnan Sabir,

   Do you have the NXP TWR-KE18F board?

    Can you reproduce your issue in the WR-KE18F board?

   You can simplify your project, just contains the issue flexIO to do 2 UARTs, then send me your project, I will find time to test it on my side.

   BTW, do you try to modify the :

SDK_2.7.0_TWR-KE18F\boards\twrke18f\driver_examples\flexio\uart\polling_transfer

   on your side, whether it works or not?

  Please also tell me which detail pin you want to use as the flexIO UART pins, then I will help you to check it on my side.

Kerry

 

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

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

1,165 Views
ad_sabir86
Contributor I

Hi Kerry

Thanks for suggestion.

I solve my problem by making own soft serial transmitter, as i need low baud rate on that (4800) using LPIT timer channel.

I asked my friend about  NXP TWR-KE18F board. He has that and will try on it using FXIO as soon as i get. 

0 Kudos

1,165 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Adnan Sabir,

  Thanks for your updated information.

   If you still need any help from my side after your friend test it, just kindly let me know.

Kerry

 

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

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos