Open paultanner opened 6 years ago
Hello, Paultanner, I am having some problems trying to work with nRF52, I change the # of NOPs but still not working, Could you provide your sorce code ? ( I just need one LED)
Thanks,
I trying to use this on a nRF52840. Did you guys figure anything out?
The core of the nRF52840 is clocked at 64MHz. Referencing this document https://learn.adafruit.com/adafruit-neopixel-uberguide/advanced-coding describing the transmission protocol, I modified the number of NOPs to the following, which works for me. Don't forget that if you are using the radio, then softdevice interrupts could scupper your timings: there are a number of ways to solve this issue (timeslots, or temporarily disabling the softdevice).
Note, I didn't bother taking into account the loop/if cycles: at 64MHz they execute quick enough to be within the margin of error - so you could probably make this tighter, if you were inclined.
Coding 1: 52 High; 28 Low Coding 0: 25 High; 58 Low
__ASM ( \ " NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t" \ " NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t" \ " NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t" \ " NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t" \ " NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t" \ " NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t" \ " NOP\n\t NOP\n\t NOP\n\t NOP\n\t" \ ); \ NRF_GPIO->OUTCLR = (1UL << PIN); \ __ASM ( \ " NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t" \ " NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t" \ " NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t" \ " NOP\n\t NOP\n\t NOP\n\t NOP\n\t" \ ); \
__ASM ( \
" NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t" \
" NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t" \
" NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t" \
" NOP\n\t" \
); \
NRF_GPIO->OUTCLR = (1UL << PIN); \
__ASM ( \
" NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t" \
" NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t" \
" NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t" \
" NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t" \
" NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t" \
" NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t NOP\n\t" \
" NOP\n\t NOP\n\t NOP\n\t NOP\n\t" \
" NOP\n\t" \
" NOP\n\t" \
);
Has anyone tried out the above code on the nRF52? I'm interested in an alternate method to the Adafruit library
The core of the nRF52840 is clocked at 64MHz. Referencing this document https://learn.adafruit.com/adafruit-neopixel-uberguide/advanced-coding describing the transmission protocol, I modified the number of NOPs to the following, which works for me. Don't forget that if you are using the radio, then softdevice interrupts could scupper your timings: there are a number of ways to solve this issue (timeslots, or temporarily disabling the softdevice).
Note, I didn't bother taking into account the loop/if cycles: at 64MHz they execute quick enough to be within the margin of error - so you could probably make this tighter, if you were inclined.
@pstids Could you include a simple but full sketch which works for you? Do you work with Arduino?
Hello I would like to use this library in nrf52832. Could you tell me about the NOP correction for 52832?
Thank you.
@schosdas: look here https://github.com/Protonerd/nrf52-neopixel
This library is based on the nRF51 lib here, modified and fully debugged by myself and my friend Stefan with a logic analyser. Works great in our project.
Kudos to lavallc and pstids for the hints, it did only take a bit of an effort to port it to nRF52
Presumably there is an assumption about the clock rate of the SoC and that's why. Tested empirically (adjusting # of NOPs): nRF51: 9,0,1,8 nRF52: 41,20, 20,41 This works ok for first LED on strip but cracks up after that. Not accurate enough. On the 52 it may be possible to do this better with interrupts. Not tried yet.