Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Reading WS2812b leftover data through I2S

Hello there,

I am currently trying to read the leftover WS2812b LED strip data which was sent using a single channel I2S. The data sent from the board (through I2S) looks like this:

with around 34 mV for high and around 2~6 mV on low. I decided not to send FFF, but 888 instead.

I am aiming to calculate the length of the LED strip. Each LED chip will read the first 24 bits of the data, cascade (discard) it, then pass it to the next one. Therefore, the strategy is to get the data after being cascaded by the last chip and calculate the length of it (which later will be divided by 24 to see how many are left).

The question is: How will I be able to read those data? I tried reading as usual (set a buffer for the i2s, start it, listen for it (delay), stop it, then check its buffer), but I got my buffer filled with all FFF instead. and a thing is that... when I tried to read anything from the pin, although I am not sending any data (the LED strip is not powered on, but connected to other's ground), there will be data, which should not happen. I assigned pin 22, 23, 24, 25 to be the i2s input pin (which will be assigned and unassigned when used or unused), and they are configured as follows:

nrf_gpio_cfg_sense_input(DIN1_PIN, NRF_GPIO_PIN_PULLDOWN, NRF_GPIO_PIN_SENSE_HIGH);

Thank you in advance.

  • Hi Einar,

    Oh, okay, I get that.

    Oh, I did not understand about what that is (even after reading the API documentation). I've set it to NRF_DRV_COMP_EVT_EN_CROSS_MASK. Now, it seems to be working fine.

    Otherwise, seems like it's too sensitive. Upon connecting an empty cable (or not connecting it), It will call the handler. Is it the VOLTAGE_THRESHOLD_TO_INT? Given that the signal (for 1) is around 1.2V ~ 1.4V, and 0V for 0, and my reference voltage is set to Internal 1.2V, then... Do I fill th_down with (0.1, 1.2) and th_up with (1.2, 1.2)? *Edit: Current configuration calls the handler at all time

    By the way, I noticed that you mentioned about interrupt priority. Were you saying that I set the interrupt (a little bit) too high?

    Thank you

  • Hi,

    If you are measuring with an unconnected input, that means that the pin is floating so it is expected that you see unpredictable interrupts in that case. Always test with a proper input signal.

    You should set the threshold levels so that they are not too close. That way you will have a hysteresis so that you avoid unwanted interrupts when if the signal fluctuates just a little bit for some reason. That does seem OK from your code snippets from a few days ago, except that you set a threshold up of 1.5 (V) and now you write that the '1' voltage on the input signal is about 1.2- 1.4 V. Clearly that does not match.

    I mentioned interrupt priority in case you are doing other tasks as well. That does not seem relevant there, but if you were making a typical real product that were doing several tasks concurrently, then that would be something you would have to think about if you wanted to do time measurements in SW.

  • even if it would pass mostly unchanged through on the data signal (which it may not),

    AIUI, they do not just pass the data through unchanged - they regenerate it.

  • Hi Einar,

    Therefore, it means that I will need to set th_down to (1.1, 1.2) and th_up to around (1.3, 1.2)? Does this threshold works as a thing, when crossed will send an interrupt? Therefore, using this configuration, interrupts are expected to be triggered when the voltage crosses the 1.1 V and 1.3 V, isn't it?

    Oh, okay, I will notice that

Related