Page 1 of 1

PCNT中断注册失败

Posted: Thu Feb 17, 2022 8:43 am
by bifenggang
下午好,我现在按照官方的pulse_count_event历程,注册中断失败

\0x1b[0;31mE (15294) pcnt: pcnt isr registration failed, maybe you need `pcnt_isr_unregister` to unregister your isr\0x1b[0m
\0x1b[0;31mE (15294) pcnt: _pcnt_isr_handler_add(252): ISR service is not installed, call pcnt_install_isr_service() first\0x1b[0m
\0x1b[0;31mE (15304) pcnt: pcnt isr registration failed, maybe you need `pcnt_isr_unregister` to unregister your isr\0x1b[0m
\0x1b[0;31mE (15314) pcnt: _pcnt_isr_handler_add(252): ISR service is not installed, call pcnt_install_isr_service() first\0x1b[0m
下面源代码,麻烦给看下,谢谢
static void pcnt_example_init(int unit,int channel, int pin)
{
/* Prepare configuration for the PCNT unit */
pcnt_config_t pcnt_config = {
// Set PCNT input signal and control GPIOs
.pulse_gpio_num = pin,//PCNT_INPUT_SIG_IO0
//.ctrl_gpio_num = PCNT_INPUT_CTRL_IO,
.channel = channel,//PCNT_CHANNEL_0,
.unit = unit,
// What to do on the positive / negative edge of pulse input?
.pos_mode = PCNT_COUNT_INC, // Count up on the positive edge
.neg_mode = PCNT_COUNT_DIS, // Keep the counter value on the negative edge
// What to do when control input is low or high?
.lctrl_mode = PCNT_MODE_KEEP, // Reverse counting direction if low
.hctrl_mode = PCNT_MODE_KEEP, // Keep the primary counter mode if high
// Set the maximum and minimum limit values to watch
.counter_h_lim = 5,
.counter_l_lim = 0,
};
/* Initialize PCNT unit */
pcnt_unit_config(&pcnt_config);

/* Configure and enable the input filter */
pcnt_set_filter_value(unit, 100);//100
pcnt_filter_enable(unit);

/* Set threshold 0 and 1 values and enable events to watch */
// pcnt_set_event_value(unit, PCNT_EVT_THRES_1, PCNT_THRESH1_VAL);
// pcnt_event_enable(unit, PCNT_EVT_THRES_1);
// pcnt_set_event_value(unit, PCNT_EVT_THRES_0, PCNT_THRESH0_VAL);
// pcnt_event_enable(unit, PCNT_EVT_THRES_0);
/* Enable events on zero, maximum and minimum limit values */
pcnt_event_enable(unit, PCNT_EVT_ZERO);
pcnt_event_enable(unit, PCNT_EVT_H_LIM);
// pcnt_event_enable(unit, PCNT_EVT_L_LIM);

/* Initialize PCNT's counter */
pcnt_counter_pause(unit);
pcnt_counter_clear(unit);

/* Install interrupt service and add isr callback handler */
pcnt_isr_service_install(0);
pcnt_isr_handler_add(unit, pcnt_example_intr_handler, (void *)unit);

// pcnt_isr_register(pcnt_example_intr_handler, NULL, 0, &user_isr_handle);
// pcnt_intr_enable(unit);

/* Everything is set up, now go to counting */
pcnt_counter_resume(unit);
}

Re: PCNT中断注册失败

Posted: Fri Feb 18, 2022 2:27 am
by bifenggang
中断里打印东西了

Re: PCNT中断注册失败

Posted: Fri Feb 18, 2022 9:33 am
by ESP_morris
这是中断重复注册的错误

Re: PCNT中断注册失败

Posted: Mon Feb 21, 2022 1:31 am
by bifenggang
初始化两路I2C就会提示这个错误,如果初始化一路就没问题

Re: PCNT中断注册失败

Posted: Mon Feb 21, 2022 2:14 am
by bifenggang
\0x1b[0;31mE (15794) pcnt: _pcnt_isr_service_uninstall(326): ISR Service not installed yet.\0x1b[0m
\0x1b[0;31mE (15794) pcnt: pcnt isr registration failed, maybe you need `pcnt_isr_unregister` to unregister your isr\0x1b[0m
\0x1b[0;32mI (15804) local_pcnt: pcnt_isr_service_install err code :261\0x1b[0m
中断明明没有重注册呀,麻烦看下谢谢

Re: PCNT中断注册失败

Posted: Tue Mar 08, 2022 3:03 am
by bifenggang
贴子沉了吗?麻烦来人看下啊

Re: PCNT中断注册失败

Posted: Tue Mar 08, 2022 3:15 am
by ESP_morris
你这代码也没有贴全啊,log显示你有调用 pcnt_isr_service_uninstall 但是你的代码中没有,检查一下你还有在哪些地方用到了PCNT. PCNT的中断只能全局注册一次.

Re: PCNT中断注册失败

Posted: Tue Mar 08, 2022 3:27 am
by bifenggang
我已经全局搜了,只注册了一次,还有目前发现如果同时初始化两路I2C以及PCNT中断就会报错,如果只初始化一路I2C就没问题,我怀疑是不是有什么冲突

Re: PCNT中断注册失败

Posted: Tue Mar 08, 2022 6:32 am
by ESP_morris
请问你用的是哪个版本的IDF? 还有,官方example运行起来有没有问题?