NXP S32K148 Evaluation Board UART Receive Fails

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

NXP S32K148 Evaluation Board UART Receive Fails

ソリューションへジャンプ
1,894件の閲覧回数
ParthiVenkat
Contributor I

I am working with NXP S32K148 Evaluation Board and developing a sample program for UART transmit and receive at the Baud rate of 115200.

Taken the Project Example S32K148_Project_LPUART and I have reconfigured the baud rate to 115200 with the following configuration

PCC->PCCn[PCC_LPUART1_INDEX] &= ~PCC_PCCn_CGC_MASK; // Ensure clk disabled for config
PCC->PCCn[PCC_LPUART1_INDEX] |= PCC_PCCn_PCS(0b110) // Source clock for LPUART1 is SPLLDIV2_CLK 
| PCC_PCCn_CGC_MASK; // Enable clock for LPUART1 regs

LPUART1->BAUD = LPUART_BAUD_SBR(0xC) /* Initialize for 115200 baud, 1 stop: */
                                 | LPUART_BAUD_OSR(28); /* SBR=12 (0xC): baud divisor = 40M/115200/29 = ~12 */

                               /* OSR=28: Over sampling ratio = 28+1=29 */
                               /* SBNS=0: One stop bit */
                               /* BOTHEDGE=0: receiver samples on the rising edge*/
                               /* M10=0: Rx and Tx use 7 to 9 bit data characters */
                               /* RESYNCDIS=0: Resync during rec'd data word supported */
                               /* LBKDIE, RXEDGIE=0: interrupts disable */
                               /* TDMAE, RDMAE, TDMAE=0: DMA requests disabled */
                               /* MAEN1, MAEN2,  MATCFG=0: Match disabled */

LPUART1->CTRL = LPUART_CTRL_RE_MASK
                                 |LPUART_CTRL_TE_MASK; /* Enable transmitter & receiver, no parity, 8 bit char: */

                               /* RE=1: Receiver enabled */
                               /* TE=1: Transmitter enabled */

With the above configuration I can able to transmit data from Evaluation Board to PC(using TTL converter).

But when I tried to UART receive data from PC to Evaluation Board is not working. The following is the code to receive the char

char LPUART1_receive_char(void) { /* Function to Receive single Char */
  char receive;
  while((LPUART1->STAT & LPUART_STAT_RDRF_MASK)>>LPUART_STAT_RDRF_SHIFT==0);
  /* Wait for received buffer to be full */
  receive= LPUART1->DATA; /* Read received data*/
  return receive;
}

Data is sent from the PC to LPUART1_RX(PTC6), but the cursor is not passing the while statement LPUART1->STAT value remained at 0xC00000.

Can you please help me on this where am missing.

0 件の賞賛
返信
1 解決策
1,841件の閲覧回数
Robin_Shen
NXP TechSupport
NXP TechSupport

I test your configuration on S32K148EVB. If I send char one by one, then it's ok. But if I send several bytes at a time, then it will not exiting the while loop due to the Receiver Overrun Flag.

Receiver Overrun Flag.png

You may need to modify the receive function by refer the API of SDK.

 

 

元の投稿で解決策を見る

0 件の賞賛
返信
5 返答(返信)
1,685件の閲覧回数
ParthiVenkat
Contributor I

Resolved. By default the code have been configured to use LPUART1, updated the configuration to use LPUART0 and the code works fine as expected.

0 件の賞賛
返信
1,878件の閲覧回数
Robin_Shen
NXP TechSupport
NXP TechSupport

It looks like you are using the S32K148_Project_LPUART
example in S32DS Example Projects for S32K1xx.
If you use the lpuart_echo_s32k148 example in S32SDK S32K1xx RTM v3, it will be much easier to use Processor Expert to modify the clock source and baud rate.

S32K1xx RTM lpuart_echo_s32k148.png

Source clock for LPUART1 is SPLLDIV2_CLK.pnginput baudrate.png

Best Regards,
Robin
-------------------------------------------------------------------------------
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 件の賞賛
返信
1,857件の閲覧回数
ParthiVenkat
Contributor I

Thank you Robin_Shen for your reply.

I think, Baud rate configuration is not the primary issue here.

Because even with S32K148_Project_LPUART code default baud rate of 9600, UART receive is not working.

It is not exiting the while loop

while((LPUART1->STAT & LPUART_STAT_RDRF_MASK)>>LPUART_STAT_RDRF_SHIFT==0);

Please help me on this.

0 件の賞賛
返信
1,842件の閲覧回数
Robin_Shen
NXP TechSupport
NXP TechSupport

I test your configuration on S32K148EVB. If I send char one by one, then it's ok. But if I send several bytes at a time, then it will not exiting the while loop due to the Receiver Overrun Flag.

Receiver Overrun Flag.png

You may need to modify the receive function by refer the API of SDK.

 

 

0 件の賞賛
返信
379件の閲覧回数
LBLDT
NXP Employee
NXP Employee

I have exactly the same problem except I configured correctly the UART, how can I overcome this OR flag issue ?

0 件の賞賛
返信