Interrupt Driven Question of Support

Tips, Tricks and methods for programming, learn ways of making your programming life easier, and share your knowledge with others.

Moderators: Benj, Mods

jlbachiochi
Posts: 7
Joined: Wed Feb 15, 2012 1:49 pm
Contact:

Interrupt Driven Question of Support

Postby jlbachiochi » Wed Feb 15, 2012 2:07 pm

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.

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

Re: Interrupt Driven Question of Support

Postby Benj » Wed Feb 15, 2012 3:34 pm

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?

jlbachiochi
Posts: 7
Joined: Wed Feb 15, 2012 1:49 pm
Contact:

Re: Interrupt Driven Question of Support

Postby jlbachiochi » Mon Feb 20, 2012 3:09 pm

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.

jlbachiochi
Posts: 7
Joined: Wed Feb 15, 2012 1:49 pm
Contact:

Re: Interrupt Driven Question of Support

Postby jlbachiochi » Fri Mar 09, 2012 6:38 pm

Hey Ben, I guess you can officially consider this a request to see how you've handled this.

--jeff

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

Re: Interrupt Driven Question of Support

Postby Benj » Mon Mar 12, 2012 10:58 am

Hello,

Here is a basic example of a circular buffer system.
Attachments
circular_buffer.fcf
(11.09 KiB) Downloaded 826 times
These users thanked the author Benj for the post (total 2):
Enamul (Fri Aug 24, 2012 2:36 pm) • medelec35 (Fri Jan 11, 2013 8:26 pm)
Rating: 10.53%
 

jlbachiochi
Posts: 7
Joined: Wed Feb 15, 2012 1:49 pm
Contact:

Re: Interrupt Driven Question of Support

Postby jlbachiochi » Mon Mar 12, 2012 7:55 pm

Thank you Ben. :D

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: Interrupt Driven Question of Support

Postby Enamul » Fri Aug 24, 2012 2:37 pm

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.
Enamul
University of Nottingham
enamul4mm@gmail.com

User avatar
jollybv
Flowcode v5 User
Posts: 339
Joined: Thu Feb 12, 2009 5:20 am
Has thanked: 77 times
Been thanked: 24 times
Contact:

Re: Interrupt Driven Question of Support

Postby jollybv » Fri Jul 05, 2013 2:41 pm

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

Kenrix2
Flowcode v5 User
Posts: 211
Joined: Tue Feb 19, 2013 9:51 pm
Has thanked: 72 times
Been thanked: 177 times
Contact:

Re: Interrupt Driven Question of Support

Postby Kenrix2 » Fri Jul 05, 2013 9:01 pm

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.

User avatar
jollybv
Flowcode v5 User
Posts: 339
Joined: Thu Feb 12, 2009 5:20 am
Has thanked: 77 times
Been thanked: 24 times
Contact:

Re: Interrupt Driven Question of Support

Postby jollybv » Mon Jul 08, 2013 6:43 am

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

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

Re: Interrupt Driven Question of Support

Postby Benj » Mon Jul 08, 2013 2:33 pm

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.
These users thanked the author Benj for the post (total 2):
Kenrix2 (Mon Jul 08, 2013 8:17 pm) • medelec35 (Sat Feb 16, 2019 11:22 am)
Rating: 10.53%
 

User avatar
jollybv
Flowcode v5 User
Posts: 339
Joined: Thu Feb 12, 2009 5:20 am
Has thanked: 77 times
Been thanked: 24 times
Contact:

Re: Interrupt Driven Question of Support

Postby jollybv » Mon Jul 08, 2013 3:01 pm

Thanks Benj but i am using V5

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

Re: Interrupt Driven Question of Support

Postby Benj » Mon Jul 08, 2013 4:32 pm

Hi Brian,

Sorry was responding to Kenrix's question...

Could you please post a V4 version of circular_buffer.fcf.

User avatar
jollybv
Flowcode v5 User
Posts: 339
Joined: Thu Feb 12, 2009 5:20 am
Has thanked: 77 times
Been thanked: 24 times
Contact:

Re: Interrupt Driven Question of Support

Postby jollybv » Tue Jul 09, 2013 7:57 am

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