--- layout: post title: MSP430 SPI weirdness date: 2020-02-23 20:25 +0100 language: 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!