UART Get started

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

UART Get started

3,404 Views
AchrafOukheir
Contributor III


Hello everyone,

I am currently working with the S32K344 (HVBMS-K344-BMU) microcontroller on S32DS and utilizing FreeRTOS in my project. I have recently added the UART component to the MCAL layer to enable UART communication.

AchrafOukheir_0-1712260332551.png

 


However, I am facing an issue with the UART functionality.

To set up the UART, I have configured the routing board accordingly in the schematic.

AchrafOukheir_1-1712260371200.png

 



Additionally, I have initialized the UART as follows:

/* Initialize the UART driver */
Uart_Init(NULL_PTR);

In order to test the UART functionality, I performed a simple example:

printf("UART\n");// Example data to send
const char *dataToSend = "Hello, UART!";
// Send data synchronously
Uart_SyncSend(UART_CHANNEL, (const uint8_t *)dataToSend, sizeof(dataToSend), 1000);vTaskDelay(pdMS_TO_TICKS(10));

However, when I sniff the pins using an oscilloscope, I am not receiving any data except for a transition from low to high.

AchrafOukheir_2-1712260413923.png

 



I would appreciate any insights or suggestions on how to troubleshoot this issue and get the UART communication working correctly. Thank you in advance for your help!

Tags (3)
0 Kudos
Reply
20 Replies

3,353 Views
AchrafOukheir
Contributor III

Hello,

I tested the UART on the example, but I'm not sure if it works with my setup because the pins are different. I want to add UART features to my project. From the example, I noticed that we should add the component, configure the routing, initialize the code, and send data via uart_asynchSend. Could you please confirm if this is the correct approach?

If not, what are the steps or approach to make the UART work in my example? What do you mean by an IP module? Should I use FlexIO? Because in the configuration, I only have two options.

Thank you very much!

0 Kudos
Reply

3,286 Views
VaneB
NXP TechSupport
NXP TechSupport

Hi @AchrafOukheir 

What do you mean by an IP module? RTD software provides low-level drivers (IP)
and high-level drivers (MCAL). MCAL provides APIs compliant with AUTOSAR and IP provides APIs with direct access to the hardware.

VaneB_0-1712601467055.png

What are the steps or approaches to make the UART work in my example? Config tools configurations, initialization of MCU driver, clocks, MCL module, pins, IRQ (if used), and UART. Then you should be able to send and receive data. Please, refer to the example codes for better reference.   

Should I use FlexIO? It is not necessary, depends on your implementation. In the example, code is used to exemplify the emulation of a UART. 

0 Kudos
Reply

3,275 Views
AchrafOukheir
Contributor III

Hello @VaneB ,

It's clear to me that IPs are drivers, but in my case, I'm not using them for UART. Instead, I'm using them to control GPIO.

I did refer to the example provided, but I'm finding it unclear in terms of configuration. It's not clear which configuration I should use, and even when I change the pins, it generates errors. It seems like I'm missing some tools configuration.
Could you please assist me with this? I've tried multiple configurations in my project, but I'm still facing difficulties. I would greatly appreciate your help with the basic configuration.

Thank you in advance.

0 Kudos
Reply

3,269 Views
VaneB
NXP TechSupport
NXP TechSupport

Hi @AchrafOukheir 

Could you share all the configurations made? Also, there is a UART training available that could help you. 

S32K3xx Communication Modules: LPUART and LIN with RTD - Training

0 Kudos
Reply

3,257 Views
AchrafOukheir
Contributor III

hi @VaneB 

As you mentioned above, it is not recommended to use IP but the training that you sent use IP , also the example is empty . I have attempted various methods, some of which were quite unconventional. Here is a sample of my work:

0 Kudos
Reply

3,214 Views
VaneB
NXP TechSupport
NXP TechSupport

Hi @AchrafOukheir 

I made a quick review of your configurations and these are my comments:

- Use Port and Dio instead of Siul2_Dio and Siul2_Port.

- Add all the pins configured in the Pins tool to the Port (LED 1, LED 2, UART TX, and UART RX) and Dio (LED 1 and LED 2) configurations of the peripherals tool.

- As you are using the UART with interrupts, configure the interrupt in the Platform driver. 

Please use as a reference the Uart_example

0 Kudos
Reply

3,185 Views
AchrafOukheir
Contributor III

hi @VaneB 

Thank you for reviewing my configuration. As you suggested, based on the UART inspiration, they used PORT and Siul2_port, which combines the use of mcal and drivers.

However, in my example, when I attempted the same configuration, I noticed that the user pin and port configurations were deleted, as shown in the picture you provided.

 

AchrafOukheir_0-1712848079919.png

Maybe This could be due to a different SDK being used ?. because In my example, I used an SDK that had the FreeRTOS operating system. It's possible that the configuration method may differ when using this SDK !!.

To clarify the configuration or provide guidance on how to configure ports and pins for LEDs and UART RX/TX, could you please provide me with the picture or details of my example you are referring to will help me better understand the specific context and provide you with accurate assistance.

Additionally, when it comes to port configuration, I don't have the same level of control as the UART example. I believe there might be a specific SDK or a button  that needs to be used to enable configuration. Here's the difference between the UART example and my example, based on the FreeRTOS SDKs.
UART Example :

AchrafOukheir_1-1712849228209.png

 



My example :

AchrafOukheir_0-1712849130529.png

 




0 Kudos
Reply

3,157 Views
VaneB
NXP TechSupport
NXP TechSupport

Hi @AchrafOukheir 

According to the provided images you are missing the value of PortPin Mscr. The following formula can obtain this value:

PortPin Mscr = PinId + PortId∗32

Where:

PortId is the numeric identifier of the port. Symbolic names will be generated for each port pin ID for the pins used for configuration.

VaneB_0-1712871714786.png

PinId is in order of the selected pin in the port. On the S32K3 platform, we have 32 pins per port, so the range of PortPinId is: 0-31.

So, for example, PortPin Mscr (PTC7) = 7 + 2∗32 = 71

0 Kudos
Reply

3,132 Views
AchrafOukheir
Contributor III

Hi @VaneB ,

It seems like we've had a lengthy discussion about our mini project, and I believe we're currently working on adding a small feature related to UART. However, I've been encountering configuration issues despite following your recommendations and the UART example. I'm struggling to succeed in my very basic project involving FreeRTOS and UART.

To provide some context, I've attached a picture of what you requested. Additionally, I've included the project itself. I would greatly appreciate any hints or solutions you could provide regarding my minor problem. Implementing UART with FreeRTOS should be relatively straightforward, but I'm finding the configuration aspect to be quite challenging and confusing.

Thank you in advance for your assistance!

AchrafOukheir_0-1712944263032.png



0 Kudos
Reply

3,062 Views
VaneB
NXP TechSupport
NXP TechSupport

Hi @AchrafOukheir 

Siul2_Port is added by default, so for the MCAL projects it needs to be deleted. The configuration of the pins can still be found in the struct named g_pin_mux_InitConfigArr. 

Also, you must initialize all pins using the Port driver by calling Port_Init() before Uart_Init().

0 Kudos
Reply

3,028 Views
AchrafOukheir
Contributor III

Hi @VaneB 
I did as you asked and delted Siul2_Port even in the uart example they are using both of them.

and of course I  initialized all pins using the Port driver by calling Port_Init() before Uart_Init().

but there is some error that blocked the project when I initialised port.

AchrafOukheir_0-1713379188135.png

thank you 



0 Kudos
Reply

3,018 Views
VaneB
NXP TechSupport
NXP TechSupport

Hi @AchrafOukheir 

I reviewed your code and looks like there are no wrong configurations of the Post module. However, I saw in your code you are using the IP functions for the UART instead of the MCAL functions.

Please refer to the Uart user manual provided. This can be found for example in the following path: C:\NXP\S32DS.3.5\S32DS\software\PlatformSDK_S32K3\RTD\Uart_TS_T40D34M40I0R0\doc

0 Kudos
Reply

3,016 Views
AchrafOukheir
Contributor III

I tried both of them :

T_Uart_Status = Lpuart_Uart_Ip_AsyncReceive(UART_CHANNEL, rxBuffer, sizeof(rxBuffer));

T_Uart_Status = Uart_AsyncReceive(UART_CHANNEL, rxBuffer, sizeof(rxBuffer));

Just to make sure it will work. but unfortunately, I think there is a probeleme in the initialisation:

Port_init(NULL_PTR);

when I initialise the port the programme stop working.

0 Kudos
Reply

3,001 Views
VaneB
NXP TechSupport
NXP TechSupport

Hi @AchrafOukheir 

Could you tell me which Port_init() instructions failed or got stuck?

0 Kudos
Reply

2,980 Views
AchrafOukheir
Contributor III

Hi @VaneB ,

in :  /* Initialize All UnUsed Port Pins */
Port_Ipw_Init_UnusedPins(pConfigPtr);

AchrafOukheir_0-1713535061582.png

this is what happening:

AchrafOukheir_1-1713535476308.png

 

but I think : Siul2_Port_Ip_Init(NUM_OF_CONFIGURED_PINS, g_pin_mux_InitConfigArr); it works for me it did the same role. 


0 Kudos
Reply

2,874 Views
VaneB
NXP TechSupport
NXP TechSupport

Hi @AchrafOukheir 

If you still have problems with the MCAL functions, please test the LpuartFlexio_Uart_Ip_Example_S32K344.

0 Kudos
Reply

2,871 Views
AchrafOukheir
Contributor III

Hi @VaneB 

about initializing the function Port_Ipw_Init_UnusedPins(pConfigPtr) during port initialization, I found the solution

After some research, I found that port initialization needs to declare not only the used ports but also the unused ports (e.g., 4, 10, 68, 69) to ensure proper JTAG functionality.

However, even after initializing the port and UART, there is still an issue with no ongoing transmission, as it stops there. I have tried using the LpuartFlexio_Uart_Ip_Example_S32K344 and the MCAL example Uart_Example_S32K344.

Could you please provide some guidance on how to resolve this problem?

 

AchrafOukheir_0-1713879611696.png

AchrafOukheir_1-1713879633463.png

 

 

 

0 Kudos
Reply

2,783 Views
VaneB
NXP TechSupport
NXP TechSupport

Hi @AchrafOukheir 

Please correct me if my understanding is wrong, but you have problems with the Lpuart_Uart_Ip_GetTransmitStatus function. Did you make the connection between both instances? Are you able to see if there is data from the UART?

0 Kudos
Reply

2,755 Views
AchrafOukheir
Contributor III

Hi @VaneB ,

It appears that the issue does not originate from the UART_getStatus() function itself, but rather from the consistent return status of UART_STATUS_OPERATION_ONGOING. Regardless of whether I tried the NXP examples or my own implementation, the UART consistently returns this value.

Based on my observations, it seems that the UART is continuously busy. This behavior persists despite my attempts to resolve the issue. To provide you with a better understanding of the problem, I have attached a screenshot showing the exact location where the problem occurs during debugging.

Furthermore, I have included the project for your reference. Feel free to take a look and provide any insights or suggestions you may have.

I appreciate any assistance you can offer in resolving this issue.

AchrafOukheir_1-1714060713465.png

 

 

0 Kudos
Reply

3,377 Views
VaneB
NXP TechSupport
NXP TechSupport

Hi @AchrafOukheir 

To ensure that the UART modules work without any problem, please test the UART example provided with the RTDs. If you still present the same behavior let me know.

Also, an observation is that we do not recommend combining IP modules with MCAL modules.

 

B.R.

VaneB

0 Kudos
Reply