SPI Week

This is the week I’m determined to cover the SPI interface. In the process of testing I uncovered an error in the ATmega4809 documentation. The documentation states for the IF Receive Complete Interrupt Flag, “IF is cleared by hardware when executing the corresponding interrupt vector.” This is not true. The flag must be manually cleared in the interrupt service routine. I lost some time on that one as the Arduino hangs when the flag isn’t cleared.

The example as SPI master is complete. Now I’m working on the SPI slave example. This is complicated by the need of an SPI master somewhere to demonstrate. I’m using a SPI master implemented in software on the same microcontroller, but it’s not really convincing (at least for me) unless it works with a master running asynchronously. So I’m doing a second slave example where the master is a second Arduino board. I’m trying my best to have illustrative examples that use no external components (other than an oscilloscope for observation), but occasionally have to break that rule.

On somewhat related fronts, I’ve reported a couple errors I found in the Arduino library on the Arduino Github site. Maybe there will be some official fixes. The major issue I found is with the Servo library which works erratically with ATmega4809 at 16MHz, and not at all at 20MHz. The fix is in my future book, but hopefully the powers that be will fix it on the Arduino end.