下午好,我现在按照官方的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);
}
PCNT中断注册失败
-
- Posts: 28
- Joined: Tue Jul 06, 2021 3:19 am
Re: PCNT中断注册失败
初始化两路I2C就会提示这个错误,如果初始化一路就没问题
-
- Posts: 28
- Joined: Tue Jul 06, 2021 3:19 am
Re: PCNT中断注册失败
\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
中断明明没有重注册呀,麻烦看下谢谢
\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
中断明明没有重注册呀,麻烦看下谢谢
-
- Posts: 290
- Joined: Wed Sep 05, 2018 6:23 am
Re: PCNT中断注册失败
你这代码也没有贴全啊,log显示你有调用 pcnt_isr_service_uninstall 但是你的代码中没有,检查一下你还有在哪些地方用到了PCNT. PCNT的中断只能全局注册一次.
-
- Posts: 28
- Joined: Tue Jul 06, 2021 3:19 am
Re: PCNT中断注册失败
我已经全局搜了,只注册了一次,还有目前发现如果同时初始化两路I2C以及PCNT中断就会报错,如果只初始化一路I2C就没问题,我怀疑是不是有什么冲突
-
- Posts: 290
- Joined: Wed Sep 05, 2018 6:23 am
Re: PCNT中断注册失败
请问你用的是哪个版本的IDF? 还有,官方example运行起来有没有问题?
Who is online
Users browsing this forum: No registered users and 103 guests