Page 1 of 1

Conflicting Conponents ( Solved )

Posted: Tue Jan 24, 2017 9:33 pm
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 .

Re: Conflicting Conponents

Posted: Wed Jan 25, 2017 10:52 am
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.

Re: Conflicting Conponents

Posted: Wed Jan 25, 2017 11:12 am
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

Re: Conflicting Conponents ( Solved )

Posted: Wed Jan 25, 2017 12:20 pm
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;

Re: Conflicting Conponents ( Solved )

Posted: Wed Jan 25, 2017 12:30 pm
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