cancel
Showing results for 
Search instead for 
Did you mean: 

How do I create an Interrupt for UART_FLAG_TXE?

HRaup.1
Associate II

I have a STM32L081KZT and I am using the LPUART.

I want to create my own Interrupt (handler) based on UART_FLAG_TXE. So basically a function that gets called whenever the UART_FLAG_TXE bit is set.

In the GCC compiler manual I have found this:

void f () __attribute__ ((interrupt ("IRQ")));

But I am totally at a loss for the syntax on how to link this with my own function.

3 REPLIES 3
KnarfB
Principal III

This works in a very different way for Cortex-M / STM32. There are many tutorials... around. It also depends on whether you are using bare metal/register level prog, HAL etc.

hth

KnarfB

HRaup.1
Associate II

Thanks for your answer.

Basically I want a function that is automatically called, when the UART_FLAG_TXE Bit is set in the LPUART_CR1 Register. My first approach was to create an IRQ Handler just for this, but I dont know how to do it. Is there any way to specifically generate an Interrupt just for this Bit?

gbm
Lead III

First, Read The Fine Manual (the Reference Manual for your microcontroller) - you will find there most of the info you need. In STM32, there is a single interrupt for each UART and it may be triggered by many different events. Have a look at functional description of the UART, then registers CR1 and ISR/SR. There are thousands of examples of USART/UART interrupt handling on the net, including this forum - see some of them, then try to implement your solution.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice