AnsweredAssumed Answered

S32K118 UART1 Configuration

Question asked by Ambarish Hundekar on Aug 8, 2018
Latest reply on Aug 13, 2018 by Diana Batrlova

Hello NXP team,

 

 

We are using S32K118 controller in our project.

 

We are using UART1 configuration for Data transmission.

1. Configuring the UART1 pins 6 and 7 As gpio pins

PCC->PCCn[PCC_PORTC_INDEX ]|=PCC_PCCn_CGC_MASK; //Enable clock for PORTC

PORTC->PCR[7]|=PORT_PCR_MUX(1); //Port C6: MUX = ALT1,gpio pin

PORTC->PCR[6]PORT_PCR_MUX(1); // Port C7: MUX = ALT1,gpio pin

PTC->PDOR &= ~(1<<7);

PTC->PDDR |= 1<<7; //Port C7 : Data Direction= output

PTC->PDDR &= ~(1<<6); // Port C6 : Data Direction= input

 

Configuring the above pins as gpio pins .

 

2. Gpio 6 and 7 pins configured as UART pins

PCC->PCCn[PCC_LPUART1_INDEX] &= ~PCC_PCCn_CGC_MASK; /* Ensure clk disabled for config */

PCC->PCCn[PCC_LPUART1_INDEX] = PCC_PCCn_PR_MASK|PCC_PCCn_CGC(1)|PCC_PCCn_PCS(3);

PORTC->PCR[UART1_TX_PIN]|=PORT_PCR_MUX(PCR_UART_CONFIG); /* Port C6: MUX = ALT2,UART1 TX */

PORTC->PCR[UART1_RX_PIN]|=PORT_PCR_MUX(PCR_UART_CONFIG); /* Port C7: MUX = ALT2,UART1 RX */

 

LPUART1->BAUD = 0x0F00001A; //9600 baud rate , 1 stop bit and no parity

//LPUART1->BAUD |= LPUART_BAUD_SBNS(1); //testing purpose 30_6_2018

LPUART1->CTRL |= LPUART_CTRL_TXINV(1);

//LPUART1->STAT |= LPUART_STAT_RXINV(1);

LPUART1->CTRL |= LPUART_CTRL_TE(ENABLE) ;

LPUART1->CTRL |= LPUART_CTRL_RE(ENABLE);

 

 

if((LPUART1->STAT & LPUART_STAT_RDRF_MASK)>>LPUART_STAT_RDRF_SHIFT== 1)

{

    buffer = LPUART1->DATA;

  buffer = buffer & 0x00FF;

if(buffer == 0xA0)

{

  //doing some operation

}

}

 

 

 

first we are configuring pins as gpio pins for some other purpose(Internal method for Auto baud detection) and then configuring the pins as UART pins.

 

 

First Implemented the code for S32K144 and tested using S32 design studio, its working fine.

but same code used for S32K118 and using S32 Design studio, but it is not working.

 

 

I have noticed one thing , if I don't configure pins as gpio pins and directly configure pins as UART pins, then it is working fine for S32K118.

 

 

Please help me in this.

 

Thank you in advance.

 

 

Outcomes