A little help for a new guy (loop() and interrupts/tasks/something else)

theskaz
Posts: 22
Joined: Mon Feb 13, 2017 5:22 pm

A little help for a new guy (loop() and interrupts/tasks/something else)

Postby theskaz » Mon Feb 13, 2017 11:26 pm

I am a .net developer playing in the IoT world. I am building a device to control some devices and read some temps. I have an ESP32, ILI9341 (using cap touch TS), Ammeter implementation, and OneWire implementation. I am using Visual Studio/Visual Micro for my IDE and its using Arduino/espressif - arduino-esp32 for compiling.

i have this code:

Code: Select all

void loop() {
	if (ts.touched())
	{
		TS_Point p = ts.getPoint();
		if ((p.x <= 100 && p.x >= 0) && (p.y <= 100 && p.y >= 0)) {
			changeStateOfBoiler();
		}
	}
	updateRssi();
	updateAmps();
	updateTemps();

}
updateTemps takes about 750ms to complete.
updateAmps() uses a millisecond counter to only actually do anything every 1 second.

Code: Select all

void updateAmps() {
	unsigned long currentMillis = millis();
	if (currentMillis - previousAmpSampleMillis >= interval)
	{
		previousAmpSampleMillis = currentMillis;
		double oldAmpValue = amps;
		rawAmpValue = analogRead(AMMETER_PIN);
		voltage = (rawAmpValue / 1023.0) * 5.00;
		amps = ((voltage - acsOffset) / mVperAmp);

		if (oldAmpValue != amps)
		{
			updateAmpsDisplay(oldAmpValue);
		}
	}
}
if ts.touched() isn't getting hit for the most part. If I tap the screen repeatedly, eventually it registers and the code fires (and then locks up) so I think that im having to hit the screen in just the right time to trigger within the loop. I know that the ESP32 has 2 cores. is there a way that I can push the ts.touch() (and other items waiting for an input) to another core so that it is realtime, and the loop continues to update as needed?
Last edited by theskaz on Tue Feb 28, 2017 7:40 pm, edited 1 time in total.

theskaz
Posts: 22
Joined: Mon Feb 13, 2017 5:22 pm

Re: A little help for a new guy (loop() and interrupts/tasks/something else)

Postby theskaz » Tue Feb 14, 2017 2:55 pm

and now that i was running a debugger and serial monitor, this is what it spits out when it locks up:

Guru Meditation Error of type LoadProhibited occurred on core 1. Exception was unhandled.
Register dump:
PC : 0x40085463 PS : 0x00060233 A0 : 0x80084940 A1 : 0x3ffdab30
A2 : 0x0000001d A3 : 0x3ffdabb4 A4 : 0x00000004 A5 : 0x3ffcb8a0
A6 : 0x3ffcb308 A7 : 0x00000000 A8 : 0x8008318c A9 : 0x3ffdab20
A10 : 0x00000003 A11 : 0x00060223 A12 : 0x00060223 A13 : 0x0000001c
A14 : 0x3ffc3dc0 A15 : 0xffffff80 SAR : 0x00000010 EXCCAUSE: 0x0000001c
EXCVADDR: 0x0000002d LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0xffffffff

Backtrace: 0x40085463:0x3ffdab30 0x40084940:0x3ffdab50 0x4008352f:0x3ffdab70 0x400e5591:0x3ffdabb0 0x400dddb2:0x3ffdabe0 0x400dddec:0x3ffdac00 0x4010c85f:0x3ffdac20 0x400fdb51:0x3ffdac40 0x400f823e:0x3ffdac60 0x400f8afc:0x3ffdad30 0x40096cc0:0x3ffdad50 0x4009bcfb:0x3ffdada0 0x400986f6:0x3ffdae00

CPU halted.

Hans Dorn
Posts: 62
Joined: Tue Feb 21, 2017 2:21 am

Re: A little help for a new guy (loop() and interrupts/tasks/something else)

Postby Hans Dorn » Tue Feb 21, 2017 8:20 pm

" LoadProhibited" probably means you tried to dereference a NULL pointer.

I guess "ts.getPoint()" returned NULL when you called it.

Cheers
Hans

Who is online

Users browsing this forum: No registered users and 115 guests