Serial interrupt with STM32

Hello Friends

I am new to arduino and i have a problem with programming STM32F103C

I want to write an interrupt routine so when ever there was a "+EVT+" it to some thing
but i don't know how to write it.

How can i write any interrupt for serial? so when ever there is a data coming serial i do some thing related to it? how can i get that data from serial?

is there anything in arduino to help me doing this?

Thanks for helping me Guys! :slight_smile:

I'm not clear on what you mean by "+EVT".

The Arduino core for STM32 (like Arduino cores in general) hooks the UART data received interrupt to move characters received by the UART to a serial input buffer. Status of the buffer is then checked by Serial.available(), typically by polling.

hi @MrMark

MrMark:

"+EVT" is just a replay from my module that sends it on uart.
i want to for example blink an led every time it comes.

i want to use serial interrupt for it. i know how to use uart and how to get or send smt but i don't know how to do it in an ISR

my module sends some codes one of them is "+EVT"

i am using STM32 pin A9 A10 which is uart1 for this and i want to use interrupt on it

i would please if you can help me
thank for your response.

The STM32 Arduino core serial character receive interrupt callback routine starts on line 294 of the link provided above. The callback is attached on line 392 under the Arduino Serial.begin() method.

Is this for learning or do you try to solve a problem?

For the latter, I would simply read serial in loop() or in a function called from loop(). Detect when a + is received and start storing in a char array. Read next char or next 3 chars and compare with what you expect. If not, restart the process.