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.
Uart Interrupt on RXINT0
-
- Valued Contributor
- Posts: 447
- http://meble-kuchenne.info.pl
- Joined: Mon Dec 07, 2020 1:00 pm
- Has thanked: 81 times
- Been thanked: 243 times
Re: Uart Interrupt on RXINT0
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.
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.
-
- Valued Contributor
- Posts: 447
- Joined: Mon Dec 07, 2020 1:00 pm
- Has thanked: 81 times
- Been thanked: 243 times
Re: Uart Interrupt on RXINT0
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.
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.