error message ledc_isr_register()

zilizii
Posts: 12
Joined: Sun Oct 29, 2017 2:19 pm

error message ledc_isr_register()

Postby zilizii » Sun Oct 29, 2017 3:16 pm

Hello,

I am a new in the ESP32 world. My goal is to understnad the basics and I would like to use only the ESP-IDF API.

I have been read the LED Controller part, and I would like to use the end interrupt of a fade effect.
Channel is configured according to the demo

Code: Select all

ledc_fade_func_install(0);
ledc_isr_register(&ledc_isr_fnc, NULL, ESP_INTR_FLAG_IRAM , NULL);
where the fnc:

Code: Select all

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

Code: Select all

	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);
            }
I guess this point of time the crash happens...
I got a nice error message:

abort() was called at PC 0x40081fb9 on core 0

Unfortunatelly I have not found too much info what I have to do for working.
Please help to me.
Trial - Error scenario for learning ESP32 :D

abcdcadb
Posts: 36
Joined: Mon Aug 07, 2017 1:28 am

Re: error message ledc_isr_register()

Postby abcdcadb » Tue Oct 31, 2017 8:09 am

HI,
there is an example about led in IDF, I strongly recommend you to run it first and later, modify it for your purpose,

about the problem you are facing (abort was called,...). i one time met when I wrongly configure I2C pins. so I guess that you did somethings related to hardware configuration. so, let try the example

zilizii
Posts: 12
Joined: Sun Oct 29, 2017 2:19 pm

Re: error message ledc_isr_register()

Postby zilizii » Tue Oct 31, 2017 9:29 am

Hello,

Thank you for your response!

The example is working well. I would like to use the isr part because of I do not want to write and calculate fixed waiting times.
I would like to use the fade end interrupt to change the behaviour of the ledc.

The Documentation of the ESP-IDF clearly described I have to use the ledc_isr_register() fnc for this. When I added the the same ESP_INTR_FLAG_IRAM to the ledc_fade_func_install(ESP_INTR_FLAG_IRAM ); seems working, but not as expected. Maybe I missunderstand the whole mechanism. The Hardware documentation mentioned all of the led channels shoul have fade end interrupt. Seems every change the interrupt function called. I think I have to learn a lot.

I would like to ask anybody to create us a tutorial for this and may be the interrupt handlings as well. I do not want to use the Arduino core anymore. For me this is in the beggining of a learning process.
Trial - Error scenario for learning ESP32 :D

abcdcadb
Posts: 36
Joined: Mon Aug 07, 2017 1:28 am

Re: error message ledc_isr_register()

Postby abcdcadb » Tue Oct 31, 2017 9:41 am

I am not sure for what is led_isr,what kind of peripheral module you want to configure for interrupt?

In case of IO interrupt (that detects the status switch on the IO pin), you may refer GPIO example

I tested interrupt functions of GPIO, timer I2c and spi of IDF2.0. idf3.0 i am not sure if there is any problem

zilizii
Posts: 12
Joined: Sun Oct 29, 2017 2:19 pm

Re: error message ledc_isr_register()

Postby zilizii » Tue Oct 31, 2017 2:31 pm

Hello

https://esp-idf.readthedocs.io/en/lates ... /ledc.html I just would like to use what the documentation said:

Use Interrupts
When configuring a LEDC channel, one of parameters selected within ledc_channel_config_t is ledc_intr_type_t and allows to enable an interrupt on fade completion.

Registration of a handler to service this interrupt is done by calling ledc_isr_register().

The configuration is the following:

Code: Select all

ledc_timer_config_t ledc_timer = {
		.bit_num = LEDC_TIMER_13_BIT, // resolution of PWM duty
		.freq_hz = 5000,              // frequency of PWM signal
		.speed_mode = LEDC_HS_MODE,   // timer mode
		.timer_num = LEDC_HS_TIMER    // timer index
		};

ledc_timer_config(&ledc_timer);

Code: Select all

ledc_channel_config_t ledc_channel[LEDC_TEST_CH_NUM] = { { .channel =
		LEDC_HS_CH2_CHANNEL, .duty = 0, .gpio_num = LEDC_HS_CH2_GPIO,
		.speed_mode = LEDC_HS_MODE, .timer_sel = LEDC_HS_TIMER, .intr_type =
				LEDC_INTR_FADE_END }, };
I got too many interrupt, I would like to get only 1 when the fade itself ended.

Thank you for your support!
Trial - Error scenario for learning ESP32 :D

zilizii
Posts: 12
Joined: Sun Oct 29, 2017 2:19 pm

Re: error message ledc_isr_register()

Postby zilizii » Tue Oct 31, 2017 3:21 pm

Hello,

In the technical documentation there is a small part:

LEDC_DUTY_CHNG_END_HSCHn_INT in the Chapter 13.2.4 Interrupts.
How I am able to invoke ISR function when this event happens?

I guess the ledc_isr_register() fnc may be the answer....
Trial - Error scenario for learning ESP32 :D

User avatar
krzychb
Posts: 229
Joined: Sat Oct 01, 2016 9:05 am
Contact:

Re: error message ledc_isr_register()

Postby krzychb » Tue Oct 31, 2017 7:48 pm

Hello zilizii,
abcdcadb wrote:I got too many interrupt, I would like to get only 1 when the fade itself ended.
What do you mean? Do you see any interrupts triggered?

If you do not see any interrupts triggered, do you check the value returned by 'ledc_isr_register()'?
What is the value?

zilizii
Posts: 12
Joined: Sun Oct 29, 2017 2:19 pm

Re: error message ledc_isr_register()

Postby zilizii » Tue Oct 31, 2017 8:32 pm

Hello

last time I used the following part of code to catch the interrupt.

I guessing I am doing something wrong / not understand the concept or missunderstand between the ESP-IDF documentation and my mind. Any help is a welcome....

I got 257 decimal value 151 times before the ESP32 reset itself....
Which is meaning :
100000001
LEDC_DUTY_CHNG_END_HSCHn_INT_ST|LEDC_HSTIMER0_OVF_INT_ST

Code: Select all

void IRAM_ATTR ledc_isr_fnc(void * arg) {

	 uint32_t l_ulCounter = REG_READ(0x3FF59180);
	 BaseType_t xHigherPriorityTaskWoken;
	 xQueueSendFromISR(queue, &l_ulCounter, &xHigherPriorityTaskWoken);
	 if( xHigherPriorityTaskWoken )
	     {
	         /* Actual macro used here is port specific. */
		 	 portYIELD_FROM_ISR();
	     }
}

void vprinttask(void * parameters) {
	uint32_t l_ulcurrent = 0;
	printf("Print Task started");
	while (1) {
		if (xQueueReceive(queue, &l_ulcurrent, portMAX_DELAY)) {
			printf("%i event happened...\n", l_ulcurrent);
		} else {
			printf("Too long wait to Message");
		}
	}

}
Results:

rst:0x7 (TG0WDT_SYS_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
W (95) boot: PRO CPU has been reset by WDT.
W (95) boot: WDT reset info: PRO CPU PC=0x400803c0
W (95) boot: WDT reset info: APP CPU PC=0x400dd3a0
I (114) boot: ESP-IDF v3.0-dev-349-g2861f3e8-dirty 2nd stage bootloader
I (136) boot: compile time 20:40:10
I (149) boot: Enabling RNG early entropy source...
I (166) boot: SPI Speed : 40MHz
I (179) boot: SPI Mode : DIO
I (192) boot: SPI Flash Size : 4MB
I (204) boot: Partition Table:
I (216) boot: ## Label Usage Type ST Offset Length
I (238) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (262) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (285) boot: 2 factory factory app 00 00 00010000 00100000
I (308) boot: End of partition table
I (321) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x05284 ( 21124) map
I (372) esp_image: segment 1: paddr=0x000152ac vaddr=0x3ffb0000 size=0x01eb4 ( 7860) load
I (386) esp_image: segment 2: paddr=0x00017168 vaddr=0x40080000 size=0x00400 ( 1024) load
I (405) esp_image: segment 3: paddr=0x00017570 vaddr=0x40080400 size=0x07450 ( 29776) load
I (469) esp_image: segment 4: paddr=0x0001e9c8 vaddr=0x400c0000 size=0x00000 ( 0) load
I (470) esp_image: segment 5: paddr=0x0001e9d0 vaddr=0x00000000 size=0x01640 ( 5696)
I (498) esp_image: segment 6: paddr=0x00020018 vaddr=0x400d0018 size=0x0fa60 ( 64096) map
I (602) boot: Loaded app from partition at offset 0x10000
I (602) boot: Disabling RNG early entropy source...
I (604) cpu_start: Pro cpu up.
I (615) cpu_start: Starting app cpu, entry point is 0x40080d18
I (0) cpu_start: App cpu up.
I (647) heap_init: Initializing. RAM available for dynamic allocation:
I (668) heap_init: At 3FFAE2A0 len 00001D60 (7 KiB): DRAM
I (687) heap_init: At 3FFB26C8 len 0002D938 (182 KiB): DRAM
I (706) heap_init: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM
I (725) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (745) heap_init: At 40087850 len 000187B0 (97 KiB): IRAM
I (764) cpu_start: Pro cpu start user code
I (822) cpu_start: Starting scheduler on PRO CPU.
I (190) cpu_start: Starting scheduler on APP CPU.
Print Task started
end
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event happened...
257 event hets Jun 8 2016 00:22:57

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


If I used a volatile uint32_t -- > incrementation the value was mot increment constantly sometime +500 difference I can get in the UART.
Trial - Error scenario for learning ESP32 :D

zilizii
Posts: 12
Joined: Sun Oct 29, 2017 2:19 pm

Re: error message ledc_isr_register()

Postby zilizii » Tue Oct 31, 2017 8:43 pm

I made a mistake
LEDC_DUTY_CHNG_END_HSCHn_INT_ST|LEDC_HSTIMER0_OVF_INT_ST was incorrect
LEDC_DUTY_CHNG_END_HSCHn_INT_RAW|LEDC_HSTIMER0_OVF_INT_RAW should be correct.....
Trial - Error scenario for learning ESP32 :D

user4_esp32
Posts: 21
Joined: Sun Nov 26, 2017 4:48 pm

Re: error message ledc_isr_register()

Postby user4_esp32 » Sun Nov 26, 2017 4:52 pm

Hello zilizii,

Thank you for posting your work with the led controller interrupts. I would like to use the LEDC_HSTIMER0_OVF_INT interrupt--would you please post your code that shows how your created an interrupt handler that responds to the LEDC_HSTIMER0_OVF_INT, as well as how you enabled the LEDC_HSTIMER0_OVF_INT? Are you changing the LEDC_INT_ENA_REG register directly?

Thanks.

Who is online

Users browsing this forum: No registered users and 15 guests