Page 1 of 1

LEDC interrupt for fade --> how it is working?

Posted: Sun Oct 29, 2017 4:19 pm
by zilizii
Hello,

I tried to create an interrupt function to check the fade action done.

Code: Select all

ledc_fade_func_install(0);
ledc_isr_register(&ledc_isr_fnc, NULL, ESP_INTR_FLAG_IRAM , NULL);

 while (1) {
            printf("1. LEDC fade up to duty = %d\n", LEDC_TEST_DUTY);
            for (ch = 0; ch < LEDC_TEST_CH_NUM; ch++) {
                ledc_set_fade_with_time(ledc_channel[ch].speed_mode,
                        ledc_channel[ch].channel, LEDC_TEST_DUTY, LEDC_TEST_FADE_TIME);
                ledc_fade_start(ledc_channel[ch].speed_mode,
                        ledc_channel[ch].channel, LEDC_FADE_NO_WAIT);
            }
            vTaskDelay(LEDC_TEST_FADE_TIME / portTICK_PERIOD_MS);
}
where the ledc_isr_fnc looks like only for cheking it is done:

Code: Select all

void IRAM_ATTR ledc_isr_fnc( void * arg) {
	printf("OMG, it is works \n");
}

I got a nice error in the log:

I (730) cpu_start: Starting scheduler on APP CPU.
1. LEDC fade up to duty = 4000
abort() was called at PC 0x40081fb9 on core 0

Backtrace: 0x40085fd8:0x3ffb0500 0x400860d7:0x3ffb0520 0x40081fb9:0x3ffb0540 0x400820d9:0x3ffb0570 0x400d215e:0x3ffb0590 0x400d21b9:0x3ffb05d0 0x40081e06:0x3ffb05f0 0x40081922:0x3ffb0610

Rebooting...
ets Jun 8 2016 00:22:57


I hope somebody is able to help to me to debug where I amde the mistake. I tried many ways, I think I do not understand the basic concept, I am in the beggining of the learning curve...

Thank you very much in advance!

Re: LEDC interrupt for fade --> how it is working?

Posted: Mon Oct 30, 2017 7:51 pm
by zilizii
Hello,

I made some modification in the main:

Code: Select all

ledc_fade_func_install(ESP_INTR_FLAG_IRAM);
ledc_isr_register(&ledc_isr_fnc, NULL, ESP_INTR_FLAG_IRAM, NULL);
in the ISR:

Code: Select all

void IRAM_ATTR ledc_isr_fnc(void * arg) {

	 uint32_t l_ulCounter = counter++;
	 BaseType_t xHigherPriorityTaskWoken;
	 xQueueSendFromISR(queue, &l_ulCounter, &xHigherPriorityTaskWoken);
	 if( xHigherPriorityTaskWoken )
	     {
	         /* Actual macro used here is port specific. */
		 	 portYIELD_FROM_ISR();
	     }
}
and I got the following, I do not understand why not got 1 interrupt the end of the fade...

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
ets Jun 8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0010,len:4
load:0x3fff0014,len:5424
ho 0 tail 12 room 4
load:0x40078000,len:0
load:0x40078000,len:12028
entry 0x40078f24
I (48) boot: ESP-IDF v3.0-dev-349-g2861f3e8-dirty 2nd stage bootloader
I (48) boot: compile time 20:40:10
I (51) boot: Enabling RNG early entropy source...
I (68) boot: SPI Speed : 40MHz
I (81) boot: SPI Mode : DIO
I (93) boot: SPI Flash Size : 4MB
I (105) boot: Partition Table:
I (117) boot: ## Label Usage Type ST Offset Length
I (139) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (163) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (186) boot: 2 factory factory app 00 00 00010000 00100000
I (209) boot: End of partition table
I (222) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x05358 ( 21336) map
I (273) esp_image: segment 1: paddr=0x00015380 vaddr=0x3ffb0000 size=0x01eb4 ( 7860) load
I (287) esp_image: segment 2: paddr=0x0001723c vaddr=0x40080000 size=0x00400 ( 1024) load
I (306) esp_image: segment 3: paddr=0x00017644 vaddr=0x40080400 size=0x07458 ( 29784) load
I (370) esp_image: segment 4: paddr=0x0001eaa4 vaddr=0x400c0000 size=0x00000 ( 0) load
I (371) esp_image: segment 5: paddr=0x0001eaac vaddr=0x00000000 size=0x01564 ( 5476)
I (399) esp_image: segment 6: paddr=0x00020018 vaddr=0x400d0018 size=0x0fd3c ( 64828) map
I (504) boot: Loaded app from partition at offset 0x10000
I (504) boot: Disabling RNG early entropy source...
I (505) cpu_start: Pro cpu up.
I (516) cpu_start: Starting app cpu, entry point is 0x40080d18
I (0) cpu_start: App cpu up.
I (549) heap_init: Initializing. RAM available for dynamic allocation:
I (570) heap_init: At 3FFAE2A0 len 00001D60 (7 KiB): DRAM
I (588) heap_init: At 3FFB26C8 len 0002D938 (182 KiB): DRAM
I (608) heap_init: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM
I (627) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (647) heap_init: At 40087858 len 000187A8 (97 KiB): IRAM
I (666) cpu_start: Pro cpu start user code
I (724) cpu_start: Starting scheduler on PRO CPU.
I (190) cpu_start: Starting scheduler on APP CPU.
queue end
task created
Print Task startedledc config ok
1. LEDC fade up to duty = 4000
0 event happened...
1 event happened...
2 event happened...
3 event happened...
4 event happened...
5 event happened...
6 event happened...
7 event happened...
8 event happened...
9 event happened...
801 event happened...
901 event happened...
918 event happened...
935 event happened...
953 event happened...
970 event happened...
988 event happened...
1411 event happened...
2012 event happened...
2614 event happened...
3216 event happened...
3875 event happened...
4534 event happened...
5193 event happened...
5852 event happened...
6511 event happened...
7170 event happened...
7829 event happened...
8517 event happened...
9205 event happened...
9893 event happened...
10581 event happened...
11268 event happened...
11956 event happened...
12644 event happened...
13332 event happened...
14019 event happened...
14707 event happened...
15395 event happened...
16083 event happened...
16771 event happened...
17458 event happened...
18175 event happened...
18892 event happened...
19609 event happened...
20326 event happened...
21042 event happened...
21759 event happened...
22476 event happened...
23193 event happened...
23909 event happened...
24626 event happened...
25343 event happened...
26060 event happened...
26777 event happened...
27493 event happened...
28210 event happened...
28927 event happened...
29644 event happened...
30361 event happened...
31077 event happened...
31794 event happened...
32511 event happened...
33228 event happened...
33944 event happened...
34661 event happened...
35378 event happened...
36095 event happened...
36812 event happened...
37528 event happened...
38245 event happened...
38962 event happened...
39679 event happened...
40396 event happened...
41112 event happened...
41829 event happened...
42546 event happened...
43263 event happened...
43979 event happened...
44696 event happened...
45413 event happened...
46130 event happened...
46847 event happened...
47563 event happened...
48280 event happened...
48997 event happened...
49714 event happened...
50430 event happened...
51147 event happened...
51864 event happened...
52581 event happened...
53298 event happened...
54014 event happened...
54731 event happened...
55448 event happened...
56165 event happened...
56882 event happened...
57598 event happened...
58315 event happened...
59032 event happened...
59749 event happened...
60465 event happened...
61182 event happened...
61899 event happened...
62616 event happened...
63333 event happened...
64049 event happened...
64766 event happened...
65483 event happened...
66200 event happened...
66916 event happened...
67633 event happened...
68350 event happened...
69067 event happened...
69784 event happened...
70500 event happened...
71217 event happened...
71934 event happened...
72651 event happened...
73368 event happened...
74084 event happened...
74801 event happened...
75518 event happened...
76235 event happened...
76951 event happened...
77668 event happened...
78385 event happened...
79102 event happened...
79819 event happened...
80535 event happened...
81252 event happened...
81969 event happened...
82686 event happened...
83402 event happened...
84119 event happened...
84836 event happened...
85553 event happened...
86270 event happened...
86986 event happened...
87703 event happened...
88420 event happened...
8913ets Jun 8 2016 00:22:57

rst:0x8 (TG1WDT_SYS_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
ets Jun 8 2016 00:22:57

rst:0x7 (TG0WDT_SYS_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)