PCNT units 4-7 cause compile/runtime errors on esp32

User avatar
TinkerBearNZ
Posts: 9
Joined: Mon Jun 17, 2019 11:20 pm

PCNT units 4-7 cause compile/runtime errors on esp32

Postby TinkerBearNZ » Wed Jan 06, 2021 10:47 pm

Not quite sure what's going on here - using "stable", v4.2. The esp32s2 only has 4 PCNT units - but I'm not building for the esp32s2, I'm building for the regular old esp32, which has 8 units.

Test case: build examples/peripherals/pcnt
Builds fine, presumably works (haven't tested that far)

Now edit pcnt/main/pcnt_example_main.c to switch from PCNT_UNIT_0 to PCNT_UNIT_4 (or 5, 6, 7) and try to compile.
Compile fails. (If you use hard-coded numbers, then it fails at runtime instead.)

Clearly components/soc/include/hal/pcnt_hal.h is intended to switch between 4 and 8 units. It makes the switch based on a value from components/soc/soc/esp32/include/soc/pcnt_caps.h (or components/soc/soc/esp32s2/include/soc/pcnt_caps.h).

I can't find any other header file that includes pcnt_caps.h, so it must be included independently? The documentation doesn't mention this, so I'm guessing it's an error?

The driver file components/driver/pcnt.c includes pcnt_caps.h, but only after pcnt_hal.h... so it has no effect.

So... is this a bug?

ESP-Marius
Posts: 74
Joined: Wed Oct 23, 2019 1:49 am

Re: PCNT units 4-7 cause compile/runtime errors on esp32

Postby ESP-Marius » Thu Jan 07, 2021 1:22 am

Yup, seems like a bug, I'll make a MR for it.

Seems like the issue is present on master as well, but it doesnt manifest itself due to the include order of the headers.

Thanks for reporting this!

Who is online

Users browsing this forum: No registered users and 107 guests