Circular buffer question (waitforvalue)

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

Post Reply
MJU
Posts: 502
Joined: Wed Nov 07, 2007 6:51 pm
Location: Antwerp Belgium
Has thanked: 121 times
Been thanked: 108 times
Contact:

Circular buffer question (waitforvalue)

Post by MJU »

I've made a flowchart with a an interrupt where I "receive a character" on the UART RX-pin (timeout = 0) and put this byte in a circular buffer.
This interrupt is enabled throughout the whole flowchart

Somewhere I need to check if a certain value "Ack" is received. I try to do this with the "waitforvalue" macro from the circular buffer.
I know that the Ack is received after max 150ms, so I set the timeout to 500ms.

But everytime it runs the waitforvalue returns a timeout.
Strange because I see the Ack appear on the microcontroller RX pin.

What could possibly be wrong?

The waitforvalue search value is "Ack", the NumChar "2", Remove content "1", TimeOut = 3000

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Circular buffer question (waitforvalue)

Post by Benj »

Hello,

My first guess would be the UART baud rate or something similar is off. Have you confirmed the micro is running at the speed you think it is using the 1 second flasher test.

Another thing is to check the UART receive interrupt is enabled AFTER the UART is initialised.

Lastly
The waitforvalue search value is "Ack", the NumChar "2"
NumChar should be 3 but this likely isn't causing the problem as this would simply look for "Ac" instead which should still be found.

MJU
Posts: 502
Joined: Wed Nov 07, 2007 6:51 pm
Location: Antwerp Belgium
Has thanked: 121 times
Been thanked: 108 times
Contact:

Re: Circular buffer question (waitforvalue)

Post by MJU »

Benj wrote:Hello,

My first guess would be the UART baud rate or something similar is off. Have you confirmed the micro is running at the speed you think it is using the 1 second flasher test.

Another thing is to check the UART receive interrupt is enabled AFTER the UART is initialised.

Lastly
The waitforvalue search value is "Ack", the NumChar "2"
NumChar should be 3 but this likely isn't causing the problem as this would simply look for "Ac" instead which should still be found.
Thank you BenJ,

The UART is initialised as the first thing in the chart.
The UART is used in the whole program and it works fine at the speed it should.
The NumChar was a remaining thing from my 1000's of tests.

Still the WaitForValue isn't working as (I guess) it should be working.
I see the "Ack" appear on the RX pin (on my logic analyser), but the macro doesn't seem to find it..

chipfryer27
Valued Contributor
Valued Contributor
Posts: 617
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 184 times
Been thanked: 195 times
Contact:

Re: Circular buffer question (waitforvalue)

Post by chipfryer27 »

Hi MJU

Could you post your chart please (or perhaps PM it)?

Guessing your better placed for the shutdown with all those beers to keep you company :)

Regards

MJU
Posts: 502
Joined: Wed Nov 07, 2007 6:51 pm
Location: Antwerp Belgium
Has thanked: 121 times
Been thanked: 108 times
Contact:

Re: Circular buffer question (waitforvalue)

Post by MJU »

chipfryer27 wrote:Hi MJU

Could you post your chart please (or perhaps PM it)?

Guessing your better placed for the shutdown with all those beers to keep you company :)

Regards
An Roman emperor (?) said:
"Give the people what they want: Sun, beer and Flowcode"
and this is just what we need in these Covid19 times :-)

I really hope everyone is safe and sound!

The lockdown is a nice moment to get my nerd genes active.
One of the things is to get Flowcode back from under it's layer of dust :-)

I've send the chart as a PM.
Many thanks (again) for your help!

chipfryer27
Valued Contributor
Valued Contributor
Posts: 617
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 184 times
Been thanked: 195 times
Contact:

Re: Circular buffer question (waitforvalue)

Post by chipfryer27 »

Hi

Pretty sure the problem is the UART RXINT0 interrupt function mentioned in other posts. Dropping back to FC7 I could get things to work and your use of the WaitForValue works fine.

You can celebrate with some of Trappiste's finest..:)

Regards

MJU
Posts: 502
Joined: Wed Nov 07, 2007 6:51 pm
Location: Antwerp Belgium
Has thanked: 121 times
Been thanked: 108 times
Contact:

Re: Circular buffer question (waitforvalue)

Post by MJU »

I've made a flowchart with FC8 that uses the circular buffer which is filled with data from the UART with an interrupt, and this doesn't work.
I've made a similar flowchart in FC7 with almost the same functionality, and now the "waitforvalue" works fine.

Frustrating because I would think that these macro's, especially those that aren't new, would work in FC8.
I always think that it's because of me that things don't work, I spent many hours to figure out what's wrong.

Please look into this problem as soon as possible.
I'm not exaggerating when I say I've maybe spent 100 hours trying to make this work, and now I know (thanks to Chipfryer27), that it's not my fault.

* Maybe Chipfryer27 helps me this much because he thinks I drink Trappist all day. But this isn't true, I sometimes drink water too :-)

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Circular buffer question (waitforvalue)

Post by Benj »

Hello MJU,

Please can you PM me your program too and I'll have a look for you. I'm using the look for value quite a lot at the moment and it is working well for me but it could be something specific in your program it's not liking. I just found and fixed a bug last week which solved this problem.

Looking for ";\n" and the data contained ";;\n" and so wasn't finding the search string. This has now been resolved and I beleive pushed to the update system.

WaitForValue uses the LookForValue in the background to do the check.

chipfryer27
Valued Contributor
Valued Contributor
Posts: 617
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 184 times
Been thanked: 195 times
Contact:

Re: Circular buffer question (waitforvalue)

Post by chipfryer27 »

Hi Benj

I think the issue is not with the CB component nor its features, instead it's with the UART RXINT0 Interrupt. I use the CB pretty much every time I use the UART without issue. As per other posts, as I couldn't simulate the Data Injector, I made up a physical circuit in hardware to test however I could not get the expected results which after investigation seemed to indicate that using FC8, the Interrupt wasn't working.

In my test I used the interrupt to branch to a simple Macro routine to place the received character into the CB as per usual. Nothing fancy at all, pretty much exactly as the examples. I did add an additional step in that when / if the Macro ever got called an LED would illuminate.

Despite an analyser confirming valid data was on the Rx pin, the Macro never got called and my LED remained off.....

Using FC7 it worked perfectly, doing as it should including all CB features I tried.

Hope this helps.

Regards

chipfryer27
Valued Contributor
Valued Contributor
Posts: 617
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 184 times
Been thanked: 195 times
Contact:

Re: Circular buffer question (waitforvalue)

Post by chipfryer27 »

Hi

I've just upgraded the machine I used to test with to latest FC8 version (8.2.x) including files and it resolved my RXINT0 Interrupt problems. I thought I'd done this already but the process hadn't completed. Maybe that was throwing a spanner in the works, but I can now confirm that the interrupt works in hardware with my FC8 and I can use the CB WaitForValue.

Regards

MJU
Posts: 502
Joined: Wed Nov 07, 2007 6:51 pm
Location: Antwerp Belgium
Has thanked: 121 times
Been thanked: 108 times
Contact:

Re: Circular buffer question (waitforvalue)

Post by MJU »

chipfryer27 wrote:Hi

I've just upgraded the machine I used to test with to latest FC8 version (8.2.x) including files and it resolved my RXINT0 Interrupt problems. I thought I'd done this already but the process hadn't completed. Maybe that was throwing a spanner in the works, but I can now confirm that the interrupt works in hardware with my FC8 and I can use the CB WaitForValue.

Regards
Great news, but my Flowcode was updates before the problem occurred.
I will work further on my project in FC7.
Thanks for all the help!

Post Reply