[SOLVED] MCPWM Capture: Cannot set 'intr_priority'.

twadek
Posts: 5
Joined: Tue Dec 19, 2023 9:29 pm

[SOLVED] MCPWM Capture: Cannot set 'intr_priority'.

Postby twadek » Mon May 13, 2024 7:28 pm

Hello,

I am having an issue when setting the interrupt priority of a capture channel.

When I compile this function, I get the error: 'mcpwm_capture_channel_config_t' has no member named 'intr_priority'.

Code: Select all

void vCreateCaptureChannels(mcpwm_cap_channel_handle_t xCaptureChannels[], mcpwm_cap_timer_handle_t xCaptureTimer) {
    ESP_LOGI(TAG, "Create Hall sensor capture channels");
    mcpwm_capture_channel_config_t xCaptureChannelConfig = {
        .prescale = 1,
        .flags.pull_up = false,
        .flags.neg_edge = true,
        .flags.pos_edge = true,
    };
    xCaptureChannelConfig.intr_priority = 0;
    const int cap_chan_gpios[3] = {DIN_HALL_1, DIN_HALL_2, DIN_HALL_3};
    for (int i = 0; i < 3; i++) {
        xCaptureChannelConfig.gpio_num = cap_chan_gpios[i];
        ESP_ERROR_CHECK(mcpwm_new_capture_channel(xCaptureTimer, &xCaptureChannelConfig, &xCaptureChannels[i]));
    }
}
This member is documented in the esp-idf docs and I have double checked that it is defined in my esp-idf build in mcpwm_cap.h:

Code: Select all

typedef struct {
    int gpio_num;                    /*!< GPIO used capturing input signal */
    int intr_priority;               /*!< MCPWM capture interrupt priority,
                                          if set to 0, the driver will try to allocate an interrupt with a relative low priority (1,2,3) */
    uint32_t prescale;               /*!< Prescale of input signal, effective frequency = cap_input_clk/prescale */
    struct {
        uint32_t pos_edge: 1;          /*!< Whether to capture on positive edge */
        uint32_t neg_edge: 1;          /*!< Whether to capture on negative edge */
        uint32_t pull_up: 1;           /*!< Whether to pull up internally */
        uint32_t pull_down: 1;         /*!< Whether to pull down internally */
        uint32_t invert_cap_signal: 1; /*!< Invert the input capture signal */
        uint32_t io_loop_back: 1;      /*!< For debug/test, the signal output from the GPIO will be fed to the input path as well */
        uint32_t keep_io_conf_at_exit: 1; /*!< For debug/test, whether to keep the GPIO configuration when capture channel is deleted.
                                            By default, driver will reset the GPIO pin at exit. */
    } flags;                           /*!< Extra configuration flags for capture channel */
} mcpwm_capture_channel_config_t;
The code works properly with the default value if I remove the line 'xCaptureChannelConfig.intr_priority = 0;'. I have also tried defining it in the configuration block (eg. '.intr_priority = 0,').

Thank you for any help you can provide.
Last edited by twadek on Tue May 14, 2024 2:58 pm, edited 1 time in total.

ESP_Sprite
Posts: 9730
Joined: Thu Nov 26, 2015 4:08 am

Re: MCPWM Capture: Cannot set 'intr_priority'.

Postby ESP_Sprite » Tue May 14, 2024 3:03 am

That is odd. That member has been introduced only somewhat recently; are you 100% sure you're looking at the mcpwm_cap.h of the esp-idf your program is compiling against?

twadek
Posts: 5
Joined: Tue Dec 19, 2023 9:29 pm

Re: MCPWM Capture: Cannot set 'intr_priority'.

Postby twadek » Tue May 14, 2024 2:58 pm

Thank you for the help. I was indeed compiling an old version unknowingly.

Who is online

Users browsing this forum: Majestic-12 [Bot] and 79 guests