SPI Basics - Custom Board

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

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


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)
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