Page 2 of 2

Re: Uart Interrupt on RXINT0

Posted: Thu Apr 01, 2021 3:56 pm
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.

Re: Uart Interrupt on RXINT0

Posted: Fri Apr 09, 2021 9:42 pm
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.

Re: Uart Interrupt on RXINT0

Posted: Fri Apr 09, 2021 9:52 pm
by LeighM
You cannot use Receive string inside a UART interrupt

Re: Uart Interrupt on RXINT0

Posted: Sun Apr 11, 2021 5:27 pm
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

Re: Uart Interrupt on RXINT0

Posted: Mon Apr 12, 2021 9:01 am
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.

Re: Uart Interrupt on RXINT0

Posted: Mon Apr 12, 2021 3:14 pm
by alanwms
Thank you Leigh