summaryrefslogtreecommitdiff
path: root/_posts/2020-02-23-msp430-spi-weirdness.md
blob: f7fe9f0662eb8dfb649694cbfea52ef066a431a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
---
layout: post
title: MSP430 SPI weirdness
date: 2020-02-23 20:25 +0100
lang: en
categories: [tech]
---

So, I've been fiddling around with my MSP430 Launchpad for a while,
with the goal to build myself an ePaper doorsign. As ePaper I used
the Waveshare ones which are controlled via SPI.

It took a lot of fiddling around, head scratching, shouting and swearing,
and probing with a logic analyzer (Logic Shrimp, which has its own issues with
Sigrok / PulseView, or v.v., since the dump was reversed) to find out how
to configure clock phase and polarity.

Since I also want to use an MFRC522 reader to "select" the content to display,
I took another dive into the datasheet to figure out which SPI mode I had to
select.

Then it hit me: Texas Instruments' definition of `CPHA=0` and `CPHA=1` was
"backwards" from what I'm used to from STmicroelectronics' STM32F1. It's
also backwards from what Wikipedia says.

For TI, `CPHA=0` means "Change on leading clock egde, capture on trailing",
while `CPHA=1` means "Capture on trailing clock edge, change on trailing".

This is pretty annoying!