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

ValueError: SPI(0) doesn't exist on Nucleo F767ZI #14388

Open
2 tasks done
luca827 opened this issue Apr 28, 2024 · 5 comments
Open
2 tasks done

ValueError: SPI(0) doesn't exist on Nucleo F767ZI #14388

luca827 opened this issue Apr 28, 2024 · 5 comments

Comments

@luca827
Copy link

luca827 commented Apr 28, 2024

Checks

  • I agree to follow the MicroPython Code of Conduct to ensure a safe and respectful space for everyone.

  • I've searched for existing issues matching this bug, and didn't find any.

Port, board and/or hardware

Nucleo F767ZI

MicroPython version

MicroPython v1.22.2

Reproduction

from machine import SPI

spi = SPI(0, sck='D13', miso='D12', mosi='D11')

Expected behaviour

No response

Observed behaviour

Traceback (most recent call last):
File "", line 3, in
ValueError: SPI(0) doesn't exist

Additional Information

No, I've provided everything above.

@luca827 luca827 added the bug label Apr 28, 2024
@dpgeorge
Copy link
Member

SPI indices start at 1 on STM32 boards. There is no SPI(0).

@luca827
Copy link
Author

luca827 commented Apr 29, 2024

Hello,
i also tryed SPI(1), SPI(2), SPI(3) and SPI(4). Only SPI(3) is working. SPI(1), SPI(2) and SPI(4) raise the ValueError: SPI(x) doesn't exist. Is this behavior expected? Where can I find the documentation which indices should work?

But thanks for your help, I only tried SPI 0-2 before. Your recommendation encouraged me to try SPI(3), which seems to worked.

@andrewleech
Copy link
Sponsor Contributor

Check the pins your specifying are correct for the SPI channel you're trying to use, stm chips generally only have 1 or 2 pins that can work for each SPI channel.

@dpgeorge
Copy link
Member

Where can I find the documentation which indices should work?

Each board has a configuration that specifies which UART/SPI/etc are defined. For the Nucleo F767ZI see here: https://github.com/micropython/micropython/blob/master/ports/stm32/boards/NUCLEO_F767ZI/mpconfigboard.h#L52-L56

Only SPI(3) is defined, on pins PB3, PB4, PB5.

@andrewleech
Copy link
Sponsor Contributor

You should be able to use the other SPI channels too by specifying the pins in the unit call like on your original example.

The supported pins for each peripheral on this chip can be found in https://github.com/micropython/micropython/blob/master/ports/stm32/boards/stm32f767_af.csv

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