I could use some suggestions on things to look at - spent several hours trying to make this work - but not having much luck.
Although I have now isolated this issue to be only occuring on ESP8266_SDK_v100150320 it does not reproduce on ESP8266_SDK_v093141121
I have a piece of code that toggles a GPIO port to drive a ws2812 LED chain. The code that drives this is fairly simple and looks like this
Code: Select all
for( i = 0; i < MAX_LEDCHAIN; i++ )
{
byte = LEDArray.ws2812array[i];
if( byte & 0x80 ) SEND_WS_1(); else SEND_WS_0();
if( byte & 0x40 ) SEND_WS_1(); else SEND_WS_0();
if( byte & 0x20 ) SEND_WS_1(); else SEND_WS_0();
if( byte & 0x10 ) SEND_WS_1(); else SEND_WS_0();
if( byte & 0x08 ) SEND_WS_1(); else SEND_WS_0();
if( byte & 0x04 ) SEND_WS_1(); else SEND_WS_0();
if( byte & 0x02 ) SEND_WS_1(); else SEND_WS_0();
if( byte & 0x01 ) SEND_WS_1(); else SEND_WS_0();
}
The SEND_WS_0 and SEND_WS_1 functions look like this.
Code: Select all
#define Set13_1 GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS,BIT13); GPIO_REG_WRITE(GPIO_ENABLE_W1TS_ADDRESS,BIT13);
#define Set13_0 GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS,BIT13);
#define init_13_GPIO PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U, FUNC_GPIO13);
void ICACHE_FLASH_ATTR SEND_WS_0()
{
uint8_t time =0;
time=2;
while (time--)
{
Set13_1;
}
time=8;
while(time--)
{
Set13_0;
}
}
void ICACHE_FLASH_ATTR SEND_WS_1()
{
uint8_t time;
time=4;
while(time--)
{
Set13_1;
}
time = 7;
while(time--)
{
Set13_0;
}
}
The problem I am getting is that the first few iterations of the loop, the timing is significantly delayed in some sort of wierd pattern, ie if I do 10 samples I get the same waveform (see below), but after the first few bytes the timing tightens up after about 10 loops. In fact the timing is perfect over perhaps 120 LED's - approx 300 iterations. But always the first LED get's corrupted.
The rest of the code set's up the ESP8266 in STATION_MODE, and connects to the network. The code also periodically sends a UDP packet to another local network device and a TCP packet to thingspeak with the captured data.
Here is an example of what I mean: