Page 1 of 1

ESP32 CAL SPI error

Posted: Sun May 09, 2021 12:40 pm
by mnfisher
Whilst trying to get SPI working on a Heltec Wifi kit..

I notice PRESCALE_VAR_X in CAL\ESP\ESP_CAL_SPI.c is defined as a MX_UINT8. (Line 106)

This is likely to not work well (it is calculated from Prescale (PR_SCALE) which is 1..800 so the result won't fit into 8 bits.

Pin assignments for hardware channels still don't seem to work correctly.

Martin

Re: ESP32 SPI Type error

Posted: Sun May 09, 2021 5:21 pm
by mnfisher
Another problem with cal_spi.

I actually noticed this when I converted an Arduino project to ESP32 (modded the project SPI to transaction mode) - found my esp32 board seemed to have died and then converted back to Arduino (changing the project type here is VERY slooowwww)

This is easily replicated by starting with an esp32 project:

Create a project for ESP32 (I used Heltec Wifi Kit 32) and add a cal_spi component. Optionally - add a call to Master_Init()

Then convert project type to Arduino (I used Nano)

Then the cal_spi component now has a prescale of up to 80MHz (and project won't compile if any calls (ie Master_Init) to SPI added)

Martin

Re: ESP32 CAL SPI error

Posted: Mon May 10, 2021 8:44 am
by LeighM
Hi Martin
I notice PRESCALE_VAR_X in CAL\ESP\ESP_CAL_SPI.c is defined as a MX_UINT8. (Line 106)
This is likely to not work well (it is calculated from Prescale (PR_SCALE) which is 1..800 so the result won't fit into 8 bits.
Thanks for the spot, but we don't actually use the PRESCALE_VAR_X variable, we use MX_SPI_PR_SCALE_X directly instead on ESP.
Pin assignments for hardware channels still don't seem to work correctly.
Do any pin assignments work for you, or is it any pins in particular?

Thanks

Re: ESP32 CAL SPI error

Posted: Mon May 10, 2021 9:19 am
by mnfisher
Thanks Leigh,

- The pins are not 'auto-selected' on choosing channel 1 or 2 and just stay 'locked' on whatever they are set to. Have to change the remap pins here...

The Prescale - threw up a compiler warning so was an easy spot whilst traying to work out why my code wouldn't compile after changing from Arduino....

Any thoughts on the 'downgrading' to Arduino problem - I manged to patch the XML on a small project (using the Compare add-on in Notepad++) but it's a delicate task on a bigger one, and FC crashes on little mistakes.

Martin

Re: ESP32 CAL SPI error

Posted: Mon May 10, 2021 10:24 am
by LeighM
- The pins are not 'auto-selected' on choosing channel 1 or 2 and just stay 'locked' on whatever they are set to. Have to change the remap pins here…
I think that’s intentional as the preferred action in most cases, i.e. the remap pins stay as the user selection when the channel is changed.
The Prescale - threw up a compiler warning so was an easy spot whilst traying to work out why my code wouldn't compile after changing from Arduino.…
Good point, I will edit the code to remove the warnings.
Any thoughts on the 'downgrading' to Arduino problem - I manged to patch the XML on a small project (using the Compare add-on in Notepad++) but it's a delicate task on a bigger one, and FC crashes on little mistakes.
Oh, I see what you mean now, that’s an interesting bug. Will investigate further.

Re: ESP32 CAL SPI error

Posted: Mon May 10, 2021 11:23 am
by LeighM
Saving and re-loading the project corrects the component properties (spotted by Ben)

Re: ESP32 CAL SPI error

Posted: Mon May 10, 2021 12:04 pm
by mnfisher
Thanks - that's an easy fix....

Re: ESP32 CAL SPI error

Posted: Wed May 12, 2021 4:24 pm
by mnfisher
Unfortunately - saving re-loading doesn't seem to work on larger programs....

Martin