Missing GPIO pulses on high CPU load - Raspberry Pi Forums


hi all,

i'm working on project i'm controlling 6 led strips (apa102) on gpio. bitbanging strips 12 gpio ports on raspberry pi 3 - 6 clock , 6 data - program written in c. seems working except sporadically seeing red flashes on parts of strips, when cpu load high.

know bitbanging spi userland not ideal in terms of timing since strips have both clock , data line not care if there temporary stall - long pulses sent strip should good. have small circuitboard shifting levels 3.3v 5v logic using number of 74ahct126 ics.

debug tried isolate problem , i'm down just pi. circuit board , led strips not connected. same problem occurs using 2a usb power supply or 70a/5v psu. connected logic analyzer clock , data pin , slowed down bitbanging (using bunch of __asm("nop")s) make sure analog input samples fast enough read data properly. problem occurs on data rate, around 100khz 4mhz or so. looking drive strips around 1mhz mark, if impossible can away half of (i how smooth 60fps animations look). in general speed not seem major issue though.

attached 2 screenshots of logic analyzer data sending 0xff 0x00 0x00 0x00 packets. first 1 fine, of time when i'm running software. second 1 taken while compiling increase cpu load , shows problem: clock pulse missing. because of data bits 'shifted' , causes flash. suspect same problem happening on data line every , then.

interesting fact tried 3 different ways of controlling gpio pins: using wiringpi (http://wiringpi.com/), bcm2835 library (http://www.airspayce.com/mikem/bcm2835/) , direct register access (http://elinux.org/rpi_gpio_code_samples ... ter_access). when i'm using wiringpi or direct register access problems i'm describing worse when i'm using bcm2835 library. captures of other 2 methods , post them here later might offer more insight.

in short - expect gpio output stall temporarily when pi busy doing other things not expect pulses dropped entirely. there shed light on issue? love avoid using bitbang kernel module if @ possible. on other hand, if fix problem more happy dig kernel compilation , device trees , going way - if that's case love tips , pointers in right direction.

isn't bit bang code source of error?


raspberrypi



Comments