UART communication failed

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

UART communication failed

Jump to solution
493 Views
SuperBeginner
Contributor III

Dear NXP, 

I use example project "s32k3xx_uart_buffer_s32ct", which can work normally.

I need use the other UART pin, so I config the other pins. 

I didn’t change the block structure.

Just only added the UART channel2 I needed and applied it.

When I use it, that project can't trigger interrupt.

I guess It wasn’t assigned to an interrupt.

1.PNG2.PNG

Can you help me to solve, please?

Thanks

#UART #CommunicationFailed

0 Kudos
Reply
1 Solution
377 Views
dragostoma
NXP Employee
NXP Employee

Hi, @SuperBeginner,

I downloaded the archive sent by you and, with some small changes, I managed to use the configured LPUART_0 instance to send and receive data in the loopback model.

What I noticed and some small mentions:

- The model uses an older version of RTD (3.0.0) and it was necessary to migrate to the new RTD (4.0.0). I suppose that this aspect may come from the prior use of the previous toolbox (1.4.0). This is where the problems you previously mentioned can also appear. So as a recommendation, try to use only one version of Toolbox in the MATLAB path.

- After the migration was done successfully, I was able to generate code based on the configuration. The configuration is done correctly, so there was no need to make any changes to it.

- Taking into account that the LPUART_6 instance used in the default configuration has the Rx and Tx pins directly connected to OpenSDA, so no additional connection is needed to use this LPUART instance, once OpenSDA is used.

dragostoma_4-1725962774604.png

dragostoma_3-1725962709947.png

- Instead, to use another instance of LPUART, an additional connection of the configured Rx and Tx pins is needed. An USB2Serial Converter can be used for this procedure. The Tx pin on the board connects to the Rx pin on the USB2Serial Converter, and the Rx pin on the board connects to the Tx pin on the USB2Serial Converter.

 

dragostoma_2-1725962572568.png

- So TXD pin 4 in the image above connects to PTA28 pin on the board (J412.23), and RXD pin 5 in the image above connects to PTA27 pin on the board (J3.20).

dragostoma_5-1725962886204.png

- After the connections are made successfully and the model is downloaded to the board, in the serial communication tool (for example RealTerm) connect the port corresponding to the USB2Serial Convert, NOT the board port, these ports being separate, but since we want the communication to be carried out using this converter, will connect to the port related to the converter.

After all these connections made successfully, you should be able to successfully communicate using the LPUART_0 instance.

dragostoma_6-1725963196476.png

I am attaching the updated model configuration for reference.

 

Hope this helps, 

Dragos

 

View solution in original post

0 Kudos
Reply
7 Replies
468 Views
dragostoma
NXP Employee
NXP Employee

Hi, @SuperBeginner.,

To change the LPUART instance used, LPUART_0 in your case, the following steps need to be followed:

- Make sure that the pins are available, not being used by another peripheral, and are correctly configured in the Port tab and in the Pins tab.

- Make sure that the instance you want to configure is correctly referenced to the clock value. You have selected UART_CLK, which is set to AIPS_SLOW_CLK. Based on the following table from the S32K3xx Reference Manual, the LPUART_0 is clocked by AIPS_PLAT_CLK. So you should either create a new clock, or modify the current value, but take into account this aspect of the clock at which each instance operates.

dragostoma_0-1725444444515.png

- You should enable the corresponding peripheral clock in the Mcu tab, in this case LPUART_0.

- Make sure that the interrupt is enabled for the corresponding instance, in this case LPUART0_IRQn, and set the Handler accordingly (LPUART_UART_IP_0_IRQHandler).

With these aspects in mind, you should successfully use the newly configured LPUART instance.

 

Hope this helps,

Dragos

0 Kudos
Reply
456 Views
SuperBeginner
Contributor III

Hi @dragostoma ,

Thank you for your reply.

Please forgive me as I am a beginner.

Can you tell me how to create a new clock which is AIPS_SLOW_CLK?

I also want to know how to enable the corresponding peripheral clock in the MCU tab and how to configure IRQ interrupts (LPUART0_IRQn & LPUART_UART_IP_0_IRQHander).

Thanks

0 Kudos
Reply
447 Views
dragostoma
NXP Employee
NXP Employee

Hi, @SuperBeginner,

1. MCU Clock Reference

To create a new clock reference or modify the already existing ones, you should access the following path in the configuration tool:

Mcu tab -> McuModuleConfiguration tab -> McuClockSettingConfig tab -> McuClockReferencePoint tab

Here you will find all the references of the clocks:

dragostoma_0-1725516691886.png

As mentioned in the Reference Manual, S32K312 has only LPUART_0 that uses AIPS_PLAT_CLK, the rest of the instances use AIPS_SLOW_CLK.

dragostoma_0-1725516848303.png

So to make sure that the other instances can still be used successfully, you can create a new reference for the UART, clocked by AIPS_PLAT_CLK.

dragostoma_1-1725517017728.png

After that, you should make sure that the UART channel you want to use, which has the LPUART_0 instance set, uses the correct clock reference, the one we just created:

dragostoma_2-1725517095566.png

 

2. MCU Clock Enablement

To enable the clock of the peripheral you want to use, you should access the following path in the configuration tool:

Mcu tab -> McuModuleConfiguration tab -> McuModeSettingConf tab -> McuPeripheral tab

Here you will find the list with all the available peripheral clocks. 

dragostoma_3-1725517403942.png

To be able to use the new instance of LPUART, the related peripheral clock must be enabled.

dragostoma_4-1725517453669.png

 

3. Interrupts Configuration

To be able to use the interrupt handlers, they must be enabled in the Platform tab, which can be found at the following path:

Platform tab -> Interrupt Controller tab

Here you will find the list with all the available interrupt handlers. 

dragostoma_5-1725518066149.png

In order to be able to use the interrupt handler related to the LPUART_0 instance, it must be enabled, a priority must be set and it must be named based on the definition and implementation in the drivers MBDT generates code on top of. In this case will be LPUART_UART_IP_0_IRQHandler.

dragostoma_6-1725518167978.png

 

I hope this information clarifies the configuration and use of a new instance of LPUART.

 

Best regards,

Dragos

0 Kudos
Reply
392 Views
SuperBeginner
Contributor III

Hi, @dragostoma 

I followed your suggestions and configured the newly added UART, but it still doesn't work. Attached is my file. Could you please help me check what might be the problem?

Thanks.

 

0 Kudos
Reply
378 Views
dragostoma
NXP Employee
NXP Employee

Hi, @SuperBeginner,

I downloaded the archive sent by you and, with some small changes, I managed to use the configured LPUART_0 instance to send and receive data in the loopback model.

What I noticed and some small mentions:

- The model uses an older version of RTD (3.0.0) and it was necessary to migrate to the new RTD (4.0.0). I suppose that this aspect may come from the prior use of the previous toolbox (1.4.0). This is where the problems you previously mentioned can also appear. So as a recommendation, try to use only one version of Toolbox in the MATLAB path.

- After the migration was done successfully, I was able to generate code based on the configuration. The configuration is done correctly, so there was no need to make any changes to it.

- Taking into account that the LPUART_6 instance used in the default configuration has the Rx and Tx pins directly connected to OpenSDA, so no additional connection is needed to use this LPUART instance, once OpenSDA is used.

dragostoma_4-1725962774604.png

dragostoma_3-1725962709947.png

- Instead, to use another instance of LPUART, an additional connection of the configured Rx and Tx pins is needed. An USB2Serial Converter can be used for this procedure. The Tx pin on the board connects to the Rx pin on the USB2Serial Converter, and the Rx pin on the board connects to the Tx pin on the USB2Serial Converter.

 

dragostoma_2-1725962572568.png

- So TXD pin 4 in the image above connects to PTA28 pin on the board (J412.23), and RXD pin 5 in the image above connects to PTA27 pin on the board (J3.20).

dragostoma_5-1725962886204.png

- After the connections are made successfully and the model is downloaded to the board, in the serial communication tool (for example RealTerm) connect the port corresponding to the USB2Serial Convert, NOT the board port, these ports being separate, but since we want the communication to be carried out using this converter, will connect to the port related to the converter.

After all these connections made successfully, you should be able to successfully communicate using the LPUART_0 instance.

dragostoma_6-1725963196476.png

I am attaching the updated model configuration for reference.

 

Hope this helps, 

Dragos

 

0 Kudos
Reply
351 Views
SuperBeginner
Contributor III

Hi @dragostoma ,

Thanks for your help, I solved my problem.

But what I don’t understand is why if I add uart0 myself, I need to configure the freeMaster block to make my uart0 operate normally.

This is really confusing!

 

0 Kudos
Reply
338 Views
dragostoma
NXP Employee
NXP Employee

Hi, @SuperBeginner,

I'm glad to hear that you managed to solve the problem.

I hope I have correctly understood the confusion you have regarding the LPUART instance set in FreeMASTER, indeed, in order for the serial communication to work correctly, the LPUART instance on which the communication is to be carried out must be chosen. Since LPUART6 was set as the default instance for communication with FreeMASTER, having the Rx and Tx pins connected directly to OpenSDA and not needing additional connections, now if you want to use the newly configured instance, LPUART0, it must be set in the FreeMASTER Config block to ensure that the connection is made on the desired instance.

I hope I understood your problem correctly and I hope this clarifies the situation.

 

Best regards,

Dragos

0 Kudos
Reply