Uart Interrupt on RXINT0

Any bugs you encounter with Flowcode should be discussed here.
LeighM
Valued Contributor
Posts: 397
http://meble-kuchenne.info.pl
Joined: Mon Dec 07, 2020 1:00 pm
Has thanked: 70 times
Been thanked: 211 times

Re: Uart Interrupt on RXINT0

Post by LeighM »

If I'm reading you correctly ...
You need to do the ReceiveChar() function in the interrupt (and very little else)
The ReceiveChar() clears the UART and sets it up ready for the next interrupt.
Without it nothing else is going to happen after the first interrupt.

alanwms
Posts: 117
Joined: Fri Dec 04, 2020 2:29 pm
Has thanked: 24 times
Been thanked: 7 times

Re: Uart Interrupt on RXINT0

Post by alanwms »

The serial interrupt routine with a simple "receive string" component does not load up my variable with a string.
I use the same component outside of an interrupt and it works fine.
The software is going into and out of the interrupt, but no results in the variable.

LeighM
Valued Contributor
Posts: 397
Joined: Mon Dec 07, 2020 1:00 pm
Has thanked: 70 times
Been thanked: 211 times

Re: Uart Interrupt on RXINT0

Post by LeighM »

You cannot use Receive string inside a UART interrupt

alanwms
Posts: 117
Joined: Fri Dec 04, 2020 2:29 pm
Has thanked: 24 times
Been thanked: 7 times

Re: Uart Interrupt on RXINT0

Post by alanwms »

Hello Leigh Can you direct me to a simple method of loading up a variable in an interrupt. I'm a little lost on the circular buffer deal

LeighM
Valued Contributor
Posts: 397
Joined: Mon Dec 07, 2020 1:00 pm
Has thanked: 70 times
Been thanked: 211 times

Re: Uart Interrupt on RXINT0

Post by LeighM »

You could have a string variable (byte array) and write the incoming ReceiveChar into that based on an index (pointer)
e.g. MyString[Index] = ReceiveChar()
Then increment the Index.
A string is simply a byte array ending with a null terminator (0)
You can then process this as a string.
You can use the detection of the CR character to terminate the string and set the Index back to zero.
Of course you also need to check that the Index does not overrun the size/length of the string variable.
The Circular Buffer component helps with these issues.

alanwms
Posts: 117
Joined: Fri Dec 04, 2020 2:29 pm
Has thanked: 24 times
Been thanked: 7 times

Re: Uart Interrupt on RXINT0

Post by alanwms »

Thank you Leigh

Post Reply