cancel
Showing results for 
Search instead for 
Did you mean: 

can access the two Uart in one controller?

SS.28
Associate II

I am using 2 Uart with interrupt function. I have enabled two interrupts at the same time. But I can access only one Uart at a time. Another Uart interrupt is no response.

Kindly support for rectify this issue.

11 REPLIES 11
Danish1
Lead II

It might be helpful to show us what you've done, so we might spot mistakes or "gotchas".

Do the UART interrupts end up calling the same function? If so, how do you know which UART has a fresh character to process?

A common "mistake" within an ISR is to try to echo the incoming character out to another UART. The problem with this is that the sending will take one character-time to send, by which time you might have missed the next incoming character. I strongly recommend putting incoming characters into a buffer that you can examine with a debugger at your leisure, rather than in the time-critical interrupt-service-routine.

I would also add that I regard the stm32-supplied HAL code somewhat restrictive - it's fine for experimenting and learning how to do things, but it takes a lot of effort to make it do more than one thing at a time.

Regards,

Danish

SS.28
Associate II

@Danish​ 

Hi ,

Thanks for replying

Currently I am working in Uart interrupt in along with LoRaWAN in RAK3172 module(STM32WLE5JC MCU).

I had worked with 2 UART interrupt without LoRa its working fine which was generated in STM32CubeIDE.

while trying to integrate one Uart interrupt with another LPUART interrupt which was used for AT commands configuration in LoRa its not working.

Below I have attached the Configuration Screenshot step by step

Kindly support for rectify this issue.

Thank you!

SS.28
Associate II

Step 1: LPUART init function0693W00000WKN3uQAH.png 

Step 2 : UART1 init function

0693W00000WKN4OQAX.png 

Step 3: Uart Msp init

0693W00000WKN4nQAH.png 

0693W00000WKN4xQAH.png 

0693W00000WKN5CQAX.png 

STEP 4 : UART MSP Deinit

0693W00000WKN5lQAH.png0693W00000WKMznQAH.png 

SS.28
Associate II

Step 5: Calling UART

0693W00000WKN7NQAX.png0693W00000WKN7DQAX.png0693W00000WKN6eQAH.png 

Step 6:Uart Callback function

 uint8_t UART1_rxBuffer[1]={0};

 uint8_t a[1]={0x00};

Don't put Blocking functions in callbacks, they are done under interrupt context, and will stop other interrupts of same/low priority from executing.

Do whatever work you need to do and leave, quickly.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
SS.28
Associate II

@Community member​ 

I have changed the NVIC priority in LPUART1 (PreemptPriority, sub Priority-->(1,0)) and UART1 (PreemptPriority, sub Priority-->(2,1)) still now I have facing same issue

Kindly guide me to rectify this issue

SS.28
Associate II

Kindly guide me!

KiptonM
Lead

The only thing a uart interrupt should do is move the data from the UART to memory (in the case of a RX interrupt) or move data from memory to the UART in the case of TX interrupt. You can add 1 or subtract 1 from a counter and set a flag, but beyond that nothing else should be in the interrupt. "

Do not process the data you received. That should be done in the main program.

Do not have anything in the interrupt that needs to wait for something else to happen. That is what they mean by no blocking functions.

If you go in and out of interrupts as fast as possible you are doing it right. If you are doing more, then you are doing it wrong.

S.Ma
Principal

Was the default lora sw define an uart interrupt handler and yours is not used? Test by trying to put breakpoint in yours.

Interrupts as said before should be very brief as they replace hw.... header byte screening, push byte in a sw fifo to queue them up for other slower non interrupt sw to manage.

You should put both uart interrupt same prio.

Put breakpoint in each isr to check you *** there. Even stop the code, check the hw registers values to make sure all is well configured, manually adjust amd let the code continue untill you get the interrupt breakpoint. You are in code debug mode, dig...