Cannot receive UART data in MKL36Z256VLH4

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Cannot receive UART data in MKL36Z256VLH4

1,344件の閲覧回数
aniketc
Contributor II

We need to use the UART functionality on pin PTE22 and PTE23 i.e.UART2_TX and UART2_RX in MKL36Z256VLH4. The data transmission is working as expected, but UART reception is not working. I have done following setting,

set the value of MUX to100 to use ALT4 in register PORTE_PCR23,

RIE, RE flags set to 1 in register UART2_C2 

clear RDMAS  in register UART2_C4 

when data is sent to microcontroller, value of UART_D does not change, also RDRF in register UART2_C2 remains 0. Also no interrupt for reception is generated. I guess the pin is not configured correctly. am I missing something?

Thanks in Advance.

Regards,

Aniket.

ラベル(1)
0 件の賞賛
返信
4 返答(返信)

988件の閲覧回数
jingpan
NXP TechSupport
NXP TechSupport

Hi,

The esay way is to follow the example:

void BOARD_InitPins(void)
{
    /* Port A Clock Gate Control: Clock enabled */
    CLOCK_EnableClock(kCLOCK_PortA);              // open clock is must
    /* Port B Clock Gate Control: Clock enabled */
    CLOCK_EnableClock(kCLOCK_PortB);
    /* Port C Clock Gate Control: Clock enabled */
    CLOCK_EnableClock(kCLOCK_PortC);

    /* PORTA1 (pin 23) is configured as LPUART0_RX */
    PORT_SetPinMux(PORTA, 1U, kPORT_MuxAlt2);             // set pin function

    /* PORTA2 (pin 24) is configured as LPUART0_TX */
    PORT_SetPinMux(PORTA, 2U, kPORT_MuxAlt2);

    /* PORTB18 (pin 41) is configured as PTB18 */
    PORT_SetPinMux(PORTB, 18U, kPORT_MuxAsGpio);

    const port_pin_config_t portc1_pin44_config = {/* Internal pull-up resistor is enabled */
                                                   kPORT_PullUp,
                                                   /* Slow slew rate is configured */
                                                   kPORT_SlowSlewRate,
                                                   /* Passive filter is disabled */
                                                   kPORT_PassiveFilterDisable,
                                                   /* Low drive strength is configured */
                                                   kPORT_LowDriveStrength,
                                                   /* Pin is configured as PTC1 */
                                                   kPORT_MuxAsGpio};
    /* PORTC1 (pin 44) is configured as PTC1 */
    PORT_SetPinConfig(PORTC, 1U, &portc1_pin44_config);

    SIM->SOPT5 = ((SIM->SOPT5 &                                             // don't forget here, some misc setting
                   /* Mask bits to zero which are setting */
                   (~(SIM_SOPT5_LPUART0TXSRC_MASK | SIM_SOPT5_LPUART0RXSRC_MASK)))

                  /* LPUART0 Transmit Data Source Select: LPUART0_TX pin. */
                  | SIM_SOPT5_LPUART0TXSRC(SOPT5_LPUART0TXSRC_LPUART_TX)

                  /* LPUART0 Receive Data Source Select: LPUART_RX pin. */
                  | SIM_SOPT5_LPUART0RXSRC(SOPT5_LPUART0RXSRC_LPUART_RX));
}

Regards,

Jing

0 件の賞賛
返信

988件の閲覧回数
aniketc
Contributor II

Hi Jing,

Thanks for your reply.

Does the sample code that you have provided is applicable for MKL36Z256VLH4?

Also are the settings applicable for  PTE23 to use as UART2_RX?

Regards,

Aniket.

0 件の賞賛
返信

988件の閲覧回数
mjbcswitzerland
Specialist V

Hi Anitket

Get the open source uTasker project below for UART operation on all chips (UART, LPUART, interrupt, DMA driven). It includes complete simulation so that you will become more efficient than standard code users.

For UART2 (it is a standard one and identical to that in all other KL parts without LPUART) and assuming Tx operation, that is you have set up mode and baud rate, the only additional register accesses needed are.
1. Ensure RDMAS is clear in UART2_C4 (note that UART0 and UART1/2 have a slightly different register set!)
2. Configure pin PTE23
_CONFIG_PERIPHERAL(E, 23, (PE_23_UART2_RX | UART_PULL_UPS));     // UART2_RX on PE23 (alt. function 4)
3. Enter interrupt handler
fnEnterInterrupt(irq_UART2_ID, PRIORITY_UART2, _SCI2_Interrupt); // enter UART2 interrupt handler
4. Enable receiver and reception interrupt
UART2_C2 |= (UART_C2_RE | UART_C2_RIE);

Regards

Mark

Kinetis: http://www.utasker.com/kinetis.html
Kinetis KL25, KL26, KL27, KL28, KL82, KL43, KL46
- http://http://www.utasker.com/kinetis/FRDM-KL25Z.html
- http://www.utasker.com/kinetis/TWR-KL25Z48M.html
- http://www.utasker.com/kinetis/FRDM-KL26Z.html
- http://www.utasker.com/kinetis/TEENSY_LC.html
- http://www.utasker.com/kinetis/FRDM-KL27Z.html
- http://www.utasker.com/kinetis/Capuccino-KL27.html
- http://www.utasker.com/kinetis/FRDM-KL28Z.html
- http://www.utasker.com/kinetis/FRDM-KL82Z.html
- http://www.utasker.com/kinetis/FRDM-KL43Z.html
- http://www.utasker.com/kinetis/TWR-KL43Z48M.html
- http://www.utasker.com/kinetis/FRDM-KL46Z.html
- http://www.utasker.com/kinetis/TWR-KL46Z48M.html

Build with: CW10.x, KDS, MCUXpresso, IAR, Keil, Greenhills, Crossworks, CooCox, Atollic, S32 Design Studio, GNU Make and Visual Studio

UART: http://www.utasker.com/docs/uTasker/uTaskerUART.PDF

Free Open Source solution: https://github.com/uTasker/uTasker-Kinetis
Working project in 15 minutes video: https://youtu.be/K8ScSgpgQ6M

For better, faster, cheaper product developments consider the uTasker developer's version, professional Kinetis support, one-on-one training and complete fast-track project solutions to set you apart from the herd : http://www.utasker.com/support.html

0 件の賞賛
返信

988件の閲覧回数
aniketc
Contributor II

Thanks Mark! 

I will configure UART2 as per your suggestion.

Regards,

Aniket.

0 件の賞賛
返信