Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SpiDevice is not disposing on ESP32-C3 and blocks the execution #1438

Open
Ellerbach opened this issue Jan 28, 2024 · 3 comments
Open

SpiDevice is not disposing on ESP32-C3 and blocks the execution #1438

Ellerbach opened this issue Jan 28, 2024 · 3 comments

Comments

@Ellerbach
Copy link
Member

Library/API/IoT binding

System.Device.Spi

Visual Studio version

No response

.NET nanoFramework extension version

No response

Target name(s)

XIAO_ESP32C3

Firmware version

latest

Device capabilities

No response

Description

SpiDevice dispose blocks the execution and is never disposing

How to reproduce

        // Frequency is 38KHz in the protocol
        float t_carrier = 1 / 38.0f;
        // Reality is that there is a 2us difference in the output as there is always a 2us bit on on SPI using MOSI
        float t_ushort = t_carrier - 2e-3f;
        // Calulate the outpout frenquency. Here = 16/(1/38 -2^-3) = 658KHz
        int freq = (int)(16.0f * 1000 / t_ushort);

        Configuration.SetPinFunction(4, DeviceFunction.SPI1_CLOCK);
        Configuration.SetPinFunction(5, DeviceFunction.SPI1_MISO);
        Configuration.SetPinFunction(6, DeviceFunction.SPI1_MOSI);

        var settings = new SpiConnectionSettings(1, -1)
        {
            ClockFrequency = freq,
            Mode = SpiMode.Mode3,
            ChipSelectLineActiveState = PinValue.High,
        };

        _spi = new SpiDevice(settings);

        Thread.Sleep(1000);
        _spi.Dispose();

// This is then never ever executed!
_spi = new SpiDevice(settings);

Thread.Sleep(1000);

_spi.Dispose();

Thread.Sleep(Timeout.Infinite);

Expected behaviour

SpiDevice should properly dispose

Screenshots

No response

Sample project or code

No response

Aditional information

No response

@Ellerbach
Copy link
Member Author

I've been trying on different ESP32-C3 models and they all have the same issue. There is no problem for a normal ESP32. So it seems related specifically to ESP32-C3.

@gwnpeter
Copy link

gwnpeter commented Mar 4, 2024

i have some test code,may be the same problem ,on xiao_esp32_c3

@josesimoes
Copy link
Member

This is fixed with nanoframework/nf-interpreter#2915.
Can you please confirm?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants