Page 1 of 1

Flickering 7 segment LEDs using core 0 for scanning

Posted: Fri Mar 08, 2019 1:50 pm
by twiereng
I have a working digital clock program using 7 segment LEDs.

Both cores are used, core 0, set at priority 1, simply scans the LEDs by using 8 GPIO pins to set the 7 segments and then enabling that digit.

Core 1 does everything else.

1. Checks if WiFI is still connected.
2. Checks the RTC to see if a second has passed and then updates the time settings.
3. Reads time and date from Internet (from NTP server).
4. Reads local temperature and humidity from BME280.
5. Reads weather information from Internet.
6. Displays weather information on 4 line LCD.

Everything works except I get ghost segments flickering on randomly, as well as some full digit flicker. In addition I get task watchdog triggered every few seconds, although this does not seem to effect anything. Tight loop in core 0 probably is setting this off, but I need speed there as 8 digits need to be scanned at least every 30 milliseconds.

I suspect the tight loop in core 0 gets interrupted by the wireless radio, which I understand runs on core 0, and this is causing the flickering.

If I swap the tasks, core 0 doing what core 1 did, etc., I have problems with the LCD display. RTC and BME280 run on I2C as well as the LCD. Running these on core 0 causes LCD to malfunction.

Any suggestions?

Thank you,
Theron Wierenga

Re: Flickering 7 segment LEDs using core 0 for scanning

Posted: Fri Mar 08, 2019 8:14 pm
by ESP_Sprite
Look at the priorities of your tasks. You probably want the task that does your LEDs to have a high priority. You can also use the I2S peripheral in parallel ('LCD') mode to more-or-less automatically scan your LEDs without using any CPU time.

Re: Flickering 7 segment LEDs using core 0 for scanning

Posted: Fri Mar 08, 2019 9:27 pm
by twiereng
Changed priority on core 0 from 1 to 0. Flickering remains, perhaps a little worse. Not sure how to do I2S peripheral in parallel ('LCD') mode to more-or-less automatically scan your LEDs without using any CPU time. Can you point me to an explanation. Attached the schematic of my circuit so you can see how I scan.

Thanks, Theron

Re: Flickering 7 segment LEDs using core 0 for scanning

Posted: Sat Mar 09, 2019 5:04 am
by mikemoy
Would you be able to use 2 of these side to side? If so, it would eliminate your timing issues. just use I2C to drive them.
https://www.adafruit.com/product/3107

Re: Flickering 7 segment LEDs using core 0 for scanning

Posted: Mon Mar 11, 2019 9:15 am
by ESP_Sprite
Changing the tasks priority from 1 to 0 won't do much, as the tasks get more priority with a *higher* priority number.