SPI Basics - Custom Board

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
mvdw
Posts: 21
Joined: Tue May 26, 2015 11:57 pm
Location: Brisbane
Contact:

SPI Basics - Custom Board

Post by mvdw » Fri May 08, 2020 9:00 pm

I have ported micropython to my board based around an STM32F767 chip, and am having trouble getting SPI working.

I have enabled SPI4 in my `mpconfigboard.h`file:

Code: Select all

#define MICROPY_HW_SPI4_NSS         (pin_E4)
#define MICROPY_HW_SPI4_SCK         (pin_E2)
#define MICROPY_HW_SPI4_MISO        (pin_E5)
#define MICROPY_HW_SPI4_MOSI        (pin_E6)
and also in the pins.csv file I have defined the correct pins for my board:

Code: Select all

D34,PE5
D35,PE6
D36,PE4
D37,PE2

SPI4_NSS,PE4
SPI4_SCK,PE2
SPI4_MISO,PE5
SPI4_MOSI,PE6
I am able to write to the SPI4 pins easily enough using the Pin class, but when I try to send something using SPI the pins do not change at all. My SPI python code is simple:

Code: Select all

from pyb import SPI
s = SPI(4)
s.init(SPI.MASTER, 1000000)
s.send(b'hello')
I am watching the lines on a logic analyser, so I know they're not toggling. <=== This is wrong (see below)

It turns out that I was looking at the wrong place in the logic analyser - once I had the triggereing setup properly SPI4 comes up clear as day. Woops!

Any clues on where to look? Hopefully it's my python and not the firmware...

Edit: Found my problem; keeping this on the forum for others' benefit.

Post Reply