Page 1 of 1

problem RXINT stm32

Posted: Tue Mar 24, 2020 4:41 pm
by maxtisc
Hello to all
I would like to present you the problem that I encountered using the STM32F407EV chip, which concerns the interrupt on the RX pin of the serial port 232, in previous experiments I have always used arduino mega2560 and with your advice I had always solved about the RX interrupt, now I wanted go to the STM32 platform, the circuit is composed of the disply touch which sends the commands of the keys via the serial port, the card recognizes them and sends the command to view the next page, pressing the menu key enter the 7 byte sequence from the display that identifies the key pressed (in decimal 101 00 05 00 255 255 255) as seen from photo 1 of the analyzer, but using stm32 the displayed data are all mixed (photo 2), while using arduino they are in the correct positions, even if it is always missing the last byte (photo 3).
in the program I also put a led that activates when it enters the data capture routine and in the STM32 it seems to work for a single touch and then hang, while on arduino it continues to receive.
The program is the same for the 2 platforms
why this? do I use a wrong method to detect data? do you have any examples to do better?
FC v8.2.0.12 Professional Version
thank you very much

Re: problem RXINT stm32

Posted: Tue Mar 24, 2020 4:43 pm
by maxtisc
sorry, no analyzer image was attached

Re: problem RXINT stm32

Posted: Tue Mar 24, 2020 5:21 pm
by LeighM
Could you post your ST ARM Flowcode version?

Re: problem RXINT stm32

Posted: Tue Mar 24, 2020 5:38 pm
by maxtisc
thanks LighM
here it is

Re: problem RXINT stm32

Posted: Tue Mar 24, 2020 6:03 pm
by LeighM
Try increasing the timeout value for the ReceiveChar(1) calls in macro RX232
e.g. ReceiveChar(2)

Re: problem RXINT stm32

Posted: Tue Mar 24, 2020 6:06 pm
by maxtisc
I had previously tried, without results

Re: problem RXINT stm32

Posted: Wed Mar 25, 2020 9:42 am
by LeighM
The circular buffer component is ideal for this kind of scenario.
To use the circular buffer, just enable the interrupt at the start of your program,
use the interrupt routine to read one character into the buffer, do not disable the interrupt.
Then in your main program you can retrieve the characters from the circular buffer.

Re: problem RXINT stm32

Posted: Wed Mar 25, 2020 1:01 pm
by maxtisc
Thanks
But a litle example?

Re: problem RXINT stm32

Posted: Wed Mar 25, 2020 5:54 pm
by LeighM

Re: problem RXINT stm32

Posted: Wed Mar 25, 2020 6:56 pm
by maxtisc
hello LeghM
I had already seen these pages and also many others, but there are passages that are not clear to me, for example in the code there is a variable called .int (also in other projects there are variables with a dot) what does it mean the point? and is not declared in the variable list
how do i store incoming data? do you automatically store them ?, how do I recall them?
sorry if they are silly questions
thanks

Re: problem RXINT stm32

Posted: Wed Mar 25, 2020 11:36 pm
by Benj
Hello,

Variables with a . before the name are local to a macro and only exist within a macro.

They could be local variables or they could be parameters or returns of the macro.

The project explorer pane can be useful to see local variables and parameters as well as other things like globals and components etc.
ProjExplorer.jpg
ProjExplorer.jpg (48.85 KiB) Viewed 4546 times

Re: problem RXINT stm32

Posted: Sun Mar 29, 2020 10:55 pm
by maxtisc
Thanks benj and LeighM
I have had the opportunity to try the circularbuffer and I see that it only partially works
the data is only partially collected, I have already tried several time outs up to the maximum, the cleaning block does not seem to work and does not reset the stored data
short description of the program
1) when I press the menu button I send a series of data from the arduino display that I collect via RXint (see screenshot) and store it on circular buffer
2) check that the first data stored is 101 if it is correct I call the macro show and display the data stored from address 0 to address 6 and display them from B1 to B7, data B1-B2-B3 are correct, B4 is wrong , B5-B6-B7 are missing (see photo)
3) on returning I clean the memory
4) after a delay to display load at 0 i the variables from D1 to D7 and display them, in reality as seen from the video the data alternate from 0 to the previous value.
tests done on arduino2560 then I will take it on stm32
how can i fix it?
thanks

Re: problem RXINT stm32

Posted: Mon Mar 30, 2020 10:07 am
by LeighM
I think the problem is that if you don't immediately get D1=101 then you print 0 and wait a second.
You need to synchronise with the incoming stream of characters.
You probably need to use WaitForValue() or loop with GetByte() waiting for the 101, then wait for GetNumberBytes() to equal the number of bytes you are expecting, to ensure that the rest of the stream has arrived in the buffer. Then you can read the values.

Re: problem RXINT stm32

Posted: Mon Apr 06, 2020 9:32 pm
by maxtisc
Hello
attached the file that I made to read the incoming bytes on the serial, on arduino it works well, (this is the only way I managed to do) as you can see in the photo I read correctly the 7 incoming bytes, but the same program does not work on STM32. in STM32 I read the B1 (value 101) replicated on all 7 bytes, also I have almost the certainty that the flushbuffer block does not work 100% as it does not clear the buffer, while indexing correctly
thanks