💾 Archived View for gem.librehacker.com › gemlog › tech › 20210723-0.gmi captured on 2024-08-18 at 17:34:06. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2021-11-30)

-=-=-=-=-=-=-

ff-mcp23s17: GPIO Input Implemented

Emacs screenshot of ff-mcp23s17 code

The ff-mcp23s17 supports GPIO input now. I wrote a demo word that pulls the bits from GPIOA, as well as another demo word that dumps the value of GPIOA to serial out, once per second. Of course, your needs might be more complicated that this, but you can use the register constants as needed in your own code.

In previous projects, I had never needed to receive anything over SPI, so I learned some new things. Receiving data over SPI is pretty simple, just checking SPDR register basically. However, one thing I stumbled over for a while is that I did not realize that it is necessary to tx data in order to rx data. This make sense, since you are just shifting data into registers when the SPI clock is running. But it is not obvious at first that in AVR, only the action of writing to SPDR actually causes the SCK to run. This makes sense as well, because if reading SPDR also caused the SCK to run, you wouldn't be able to transmit your data and grab incoming data in the same SCK run, which might be desirable.

Comments

Alaskalinuxuser, 2021-07-23

Great progress!