Conflicting Conponents ( Solved )

A forums to allow bugs and problems with Flowcode v7 to be reported and resolved.

Moderator: Benj

Post Reply
User avatar
Alan_37
Posts: 179
Joined: Sun May 01, 2016 8:36 pm
Has thanked: 51 times
Been thanked: 54 times
Contact:

Conflicting Conponents ( Solved )

Post by Alan_37 »

Hi

After some hard time investigating what is wrong I found that the Servo controller is conflicting with the WS2812 Component
If i Initialize the servo controller before the WS2812 Macro , Ws2812 will not work properly.

If i remove the initialize servo controller than all works OK , maybe there are same variables with same name or something
I made i very simple program where the conflict happens .
Attachments
Flowcode1.fcfx
(16.28 KiB) Downloaded 231 times
Last edited by Alan_37 on Wed Jan 25, 2017 11:13 am, edited 1 time in total.

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: Conflicting Conponents

Post by Benj »

Hi Alan,

The servo component uses interrupts to bit bang out the servo motor signals. The WS2812 component uses very tight timings to bit bang out the LED signals.

If the servo interrupt kicks in during the WS2812 refresh then it will completely destroy the LED control timings.

You could disable interrupts before calling the refresh function and re-enable them again afterwards and that should help things.

To disable interrupts on your ATMEGA2560 use the following code in a C icon.

Code: Select all

cli();
Then to re-enable the interrupts again.

Code: Select all

sei();
Let us know how you get on.

User avatar
Alan_37
Posts: 179
Joined: Sun May 01, 2016 8:36 pm
Has thanked: 51 times
Been thanked: 54 times
Contact:

Re: Conflicting Conponents

Post by Alan_37 »

Hi Benj

Yes Confirmed , that was the problem and the C-code works 100% .

Just another couple of questions

Is there any other components that you remember with the same issue ?
The C-Code provided works only on Arduino 2560 ?

Thanks very much for your fast Support

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: Conflicting Conponents ( Solved )

Post by Benj »

Hi Alan,

Interrupts will effect any component that has critical timings for example a software UART would have similar problems though a hardware UART would not. Software I2C and Software SPI don't have the same problem as they rely on a clock to drive the data rather than a timing critical baud rate.

We try and allow things to work together as best as possible but if you're unsure about the consequences of a specific combination then you can always ask.

The C code should work for any AVR device. For a PIC (8/16 bit) the code might look like this.

Disable Interrupts

Code: Select all

INTCONbits.GIE = 0;
Enable Interrupts

Code: Select all

INTCONbits.GIE = 1;

User avatar
Alan_37
Posts: 179
Joined: Sun May 01, 2016 8:36 pm
Has thanked: 51 times
Been thanked: 54 times
Contact:

Re: Conflicting Conponents ( Solved )

Post by Alan_37 »

Hi Ben

That is very interesting and good to know , my intention is port the project to the STM 32bit ARM Processors
when the update is out and peripherals supported .

Ok then thanks again .

Regards

Post Reply