I connected a 4-digit 7-segment display to the GPIO-port. It uses 8 ports for the LEDs and 4 ports for multiplexing via PNP-transistors. It is running so far with a loop written in C program:
while(1) {
for(j = 0; j < 4; j++) { // Loop through 4 digits
clearSegments();
writeSegments(j+1, values[j]);
delayMicroseconds(500); // approximately 500 Hz total refresh frequency
}
}
In general this works fine but maybe once or two times a second there is some irregular flickering. There is no XSession running and only MPD plays music. I run the program with a very high priority:
nice -n -19 /home/pi/mpd/C/main &
What else can I do?
I already did some research and found out the following options:
- Create own kernel module which scheduling tasks (refer to tldp.org).
- Enable high resolution timers by patching the kernel (refer to raspberrypi.stackexchange.com).
Both ways seem to be very complicated for just using such a simple display.
What do you suggest?