add a second circular buffer?

For general Flowcode discussion that does not belong in the other sections.
Post Reply
flowcode-developer
Posts: 37
http://meble-kuchenne.info.pl
Joined: Thu Feb 02, 2023 9:32 pm
Has thanked: 19 times
Been thanked: 3 times

Flowcode v10 add a second circular buffer?

Post by flowcode-developer »

Hi,
I am programming an AVR ATMEGA2560 with AVR chipset. My program is supposed to poll two devices on (inspectra)ch1 and ch3(weather) via UART. There is a Modbus slave that is sending out the cleaned info on ModbusSlave ch2. I have been successful with inspectra and ModbusSlave working in tandem. I am using a circular buffer to capture the info. Now I am adding another device the weather station on ch3.

My question is since I am adding another device do I need to add a 2nd circular buffer? If I do would I add it in just like the first buffer as a interrupt?
I have attached my work below.

Thank you
Attachments
inspectra5.fcfx
current work
(71.78 KiB) Downloaded 296 times
proof that avr is sending message
proof that avr is sending message
logic_send loop1.PNG (94.45 KiB) Viewed 2643 times

mnfisher
Valued Contributor
Posts: 1453
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 135 times
Been thanked: 707 times

Re: add a second circular buffer?

Post by mnfisher »

Hi,

Yes - you can have multiple circular buffers. The data will be 'fed' into these from an interrupt handler (uart_rx on RXInt0 in your code). If you have data coming into a second UART - then it would be easiest to have a second buffer and use a RxInt to load the data into it on receive. Note that FC doesn't seem to give a default interrupt handler for RxInt2 (UART channel 3 :-; ) - but it is possible to handle it using custom code ..

Martin

flowcode-developer
Posts: 37
Joined: Thu Feb 02, 2023 9:32 pm
Has thanked: 19 times
Been thanked: 3 times

Re: add a second circular buffer?

Post by flowcode-developer »

Hi so if I understand correctly I should not do what I did below? I need to make an RXINT2 since FC does not have one made for me to use. Is there a way I can reverse engineer RXINT1 or RXINT0 so I can make an RXINT2?

Thank you!
Attachments
rxUART.PNG
rxUART.PNG (128.74 KiB) Viewed 2631 times

flowcode-developer
Posts: 37
Joined: Thu Feb 02, 2023 9:32 pm
Has thanked: 19 times
Been thanked: 3 times

Re: add a second circular buffer?

Post by flowcode-developer »

I found this article on custom interrupts for AVR. https://www.flowcode.co.uk/wiki/index.p ... upts_-_AVR
How can I customize this for channel 3?

Code: Select all

Enable code:

UCSRB |= ((1 << RXCIE) | (1 << RXEN)); // enable USART receiver and receive interrupts


Disable code:

//UCSRB &= ~(1 << RXCIE); // disable USART receive interrupts


Handler code:

ISR(USART_RXC_vect) // USART receive vector

{

FCM_%n(); // Call Flowcode Macro

}

mnfisher
Valued Contributor
Posts: 1453
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 135 times
Been thanked: 707 times

Re: add a second circular buffer?

Post by mnfisher »

Take a look at https://www.matrixtsl.com/wiki/index.ph ... upts_-_AVR

Also if you right click the enable interrupt block and select customise C code to look under the hood...

BenR
Matrix Staff
Posts: 1924
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 501 times
Been thanked: 684 times

Re: add a second circular buffer?

Post by BenR »

Hello,

I've now added the missing UART interrupts for channels 3 and 4 as well as TX interrupts for all four UARTs. The update should now be available via the Help -> Library updates.

Post Reply