Page 1 of 1

Interrupt Driven Question of Support

Posted: Wed Feb 15, 2012 2:07 pm
by jlbachiochi
Often when using a UART, receiving data requires an interrupt to keep its receiver empty. This usually includes stuffing any data into a ring buffer. Polling (which I think is what's used in the RS-232 object available as a standard component) can be used when throughput is low enough. To create this RX macro does Flowcode give me any direct support, like easy access to the micro's predefined registers or am I essentially writing all the code without any 'help' from the Flowcode app? While an RX interrupt service routine and ring buffer may actually be two separate macros, I think you get my drift.
Trying to stay within the ?limits? of Flowcode. As an alternative to UART polling might I place the UART poll into a timer interrupt and have that interrupt build a string out of characters as they arrive. I could then look at that string in my main loop whenever I choose. Of course this assumes I will be able to empty the string before it gets full or at least put up with lost characters. This sounds like a kludge, but might allow writing the macro without external coding.

Re: Interrupt Driven Question of Support

Posted: Wed Feb 15, 2012 3:34 pm
by Benj
Hello,

Flowcode v4 and v5 allow for the UART receive interrupt to be supported directly in your flowchart. I have made many applications using circular buffers to store data as it is coming in for processing later on.

I can provide you with a quick example in Flowcode if you wish. Are you using v4 or v5?

Re: Interrupt Driven Question of Support

Posted: Mon Feb 20, 2012 3:09 pm
by jlbachiochi
Ben,

Thanks for the quick reply. Although this was more of a question of supporting capabilities of Flowcode, I always find it educational to view another's code. I am presently reviewing V5. If I'm going to use a product that is touted to simplify my coding efforts and I have to spend half my time coding pieces of a puzzle that I will then be able to build easily, it kind of defeats the purpose. Thanks again for your quick input.

Re: Interrupt Driven Question of Support

Posted: Fri Mar 09, 2012 6:38 pm
by jlbachiochi
Hey Ben, I guess you can officially consider this a request to see how you've handled this.

--jeff

Re: Interrupt Driven Question of Support

Posted: Mon Mar 12, 2012 10:58 am
by Benj
Hello,

Here is a basic example of a circular buffer system.

Re: Interrupt Driven Question of Support

Posted: Mon Mar 12, 2012 7:55 pm
by jlbachiochi
Thank you Ben. :D

Re: Interrupt Driven Question of Support

Posted: Fri Aug 24, 2012 2:37 pm
by Enamul
Hi Ben,
That's very useful. I should have notice this earlier. It's help a lot to concentrate it other stuff while reading from RS232.

Re: Interrupt Driven Question of Support

Posted: Fri Jul 05, 2013 2:41 pm
by jollybv
Hi guys

Im trying to understand this circular buffer you have a calculation in rx_uart (test = (rx_end + 1) MOD max_size) i understand the first half but do not understand the MOD is it a formula in flowcode and the other thing i don't understand is the variable rx_data [100] is it 100 veritable one for each character received buy the uart. Is there some place i can find all the different formula's for flowcode.

Brian

Re: Interrupt Driven Question of Support

Posted: Fri Jul 05, 2013 9:01 pm
by Kenrix2
Hello Benj,

Could you please post a V4 version of circular_buffer.fcf. I have an application using the rs232 component where a lot of data is streaming out of a PC which is updated every 1/10 of a second to a series of PIC's. Unfortunately, sometimes a byte gets dropped. A buffer method might solve my problem. I Thank you in advance for your help.

Re: Interrupt Driven Question of Support

Posted: Mon Jul 08, 2013 6:43 am
by jollybv
Hello Benj

I am trying to understand this circular buffer what I'm doing is sending 6 characters e.g. @=(123)* the at is the start bit the = is wait to revive data then the next 3 characters are the data and the * is the end Char. what i'm having a problem is how do i take the 3 bits rx_uart 2, 3 & 4 (hex 49, 50, 51) converting it to (123)and combining all 3 variables to a number 123 that i can store in eeprom

thanks
Brian

Re: Interrupt Driven Question of Support

Posted: Mon Jul 08, 2013 2:33 pm
by Benj
Hi Brian,

MOD also known as the C constructor % is basically performing a modulus operation, its a bit like saying this is the maximum rollover value so:
3 mod 5 = 3
4 mod 5 = 4
5 mod 5 = 0
6 mod 5 = 1
7 mod 5 = 2

The Rx_Data[100] is basically an array of 100 elements each with the same properties as the singular variable.

All the Flowcode functions and syntax should be available in the tabs of the calculation icon.

Converting an ASCII value into decimal is quite simple. For a number you would subtract '0' with the single quotes from the incoming ASCII data and this would give you the decimal value. You could use 48 decimal instead of '0'.

e.g.
'0' - '0' = 0
'1' - '0' = 1
...
'9' - '0' = 9

You would then combine the number into a variable like this.

total = units
total = total + (tens * 10)
total = total + (hundreds * 100)

If I get ten mins later today I will look into creating a v4 rolling buffer example.

Re: Interrupt Driven Question of Support

Posted: Mon Jul 08, 2013 3:01 pm
by jollybv
Thanks Benj but i am using V5

Re: Interrupt Driven Question of Support

Posted: Mon Jul 08, 2013 4:32 pm
by Benj
Hi Brian,

Sorry was responding to Kenrix's question...
Could you please post a V4 version of circular_buffer.fcf.

Re: Interrupt Driven Question of Support

Posted: Tue Jul 09, 2013 7:57 am
by jollybv
Hi Benj

I sort of understand the circular buffer what i would like to know dose it only work with single bit transmission or can i send strings as well.

Regards
Brian