cancel
Showing results for 
Search instead for 
Did you mean: 

UART Question

gvigelette
Associate II
Posted on September 03, 2014 at 18:42

Hello everyone, I was wondering how to turn of the UART Interrupt, I am using HAL_UART_Receive_IT to receive incoming characters on the serial port.  periodically I want to take over the port and control it manually, is there a way to stop IT function once it is waiting?

I have tried:

__HAL_LOCK(&huart1);

__HAL_UART_DISABLE_IT(&huart1, UART_IT_PE);

  __HAL_UART_DISABLE_IT(&huart1, UART_IT_ERR);

__HAL_UNLOCK(&huart1);

__HAL_UART_DISABLE_IT(&huart1, UART_IT_RXNE);

Thanks in advance,

George
6 REPLIES 6
Andrew Neil
Chief II
Posted on September 04, 2014 at 14:12

I have tried:

And what was the result?

gvigelette
Associate II
Posted on September 04, 2014 at 14:42

Hi Neil,

The result ends up being that I don't receive characters from the uart after that point either through the interrupt or manually and trying to put the device back into interrupt mode errors.  I could probably try to reset the device and put it in manual mode that would probably work, I was just figuring there was some way to do it seamlessly.  I would guess that there are some NVIC calls that may need to be made in addition to the uart calls to cancel the pending interrupt on the uart?  The issue is that I am reading a cellular chipset so I have the uart setup in interrupt mode processing one character at a time, because the chipset will send messages when a call comes in or a sms message etc. When I want to send an sms message or http request I would like to stop the interrupt and control the port manually.    

Andrew Neil
Chief II
Posted on September 04, 2014 at 19:21

''trying to put the device back into interrupt mode errors''

And what does that mean, exactly?

''When I want to send an sms message or http request I would like to stop the interrupt and control the port manually''

Why??
gvigelette
Associate II
Posted on September 05, 2014 at 16:19

Hi Neil,

During normal operation the uart is in interrupt mode pulling a character at a time building a string waiting for the carriage return then ships the string to the processor.  During http requests i would like to break out of that mode so that I can read the bytes form the web manually, such as using the hal_receive 100 bytes of data at a time until all the data is downloaded.

Thanks,

George

Posted on September 09, 2014 at 10:34

Hi George,

You can use the macro __HAL_UART_DISABLE_IT(), in order to stop the HAL_UART_Receive_IT() process.

Regards.

andrey
Associate
Posted on February 03, 2015 at 05:43