ESP32 CAL SPI error

Any bugs you encounter with Flowcode should be discussed here.
Post Reply
mnfisher
Valued Contributor
Posts: 1549
http://meble-kuchenne.info.pl
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 138 times
Been thanked: 737 times

ESP32 CAL SPI error

Post 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

mnfisher
Valued Contributor
Posts: 1549
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 138 times
Been thanked: 737 times

Re: ESP32 SPI Type error

Post 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

LeighM
Valued Contributor
Posts: 458
Joined: Mon Dec 07, 2020 1:00 pm
Has thanked: 82 times
Been thanked: 246 times

Re: ESP32 CAL SPI error

Post 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

mnfisher
Valued Contributor
Posts: 1549
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 138 times
Been thanked: 737 times

Re: ESP32 CAL SPI error

Post 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

LeighM
Valued Contributor
Posts: 458
Joined: Mon Dec 07, 2020 1:00 pm
Has thanked: 82 times
Been thanked: 246 times

Re: ESP32 CAL SPI error

Post 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.

LeighM
Valued Contributor
Posts: 458
Joined: Mon Dec 07, 2020 1:00 pm
Has thanked: 82 times
Been thanked: 246 times

Re: ESP32 CAL SPI error

Post by LeighM »

Saving and re-loading the project corrects the component properties (spotted by Ben)

mnfisher
Valued Contributor
Posts: 1549
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 138 times
Been thanked: 737 times

Re: ESP32 CAL SPI error

Post by mnfisher »

Thanks - that's an easy fix....

mnfisher
Valued Contributor
Posts: 1549
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 138 times
Been thanked: 737 times

Re: ESP32 CAL SPI error

Post by mnfisher »

Unfortunately - saving re-loading doesn't seem to work on larger programs....

Martin

Post Reply