Close

SPI details

A project log for self-contained SD based AVR programmer

Workbench programming tool

nick-sayerNick Sayer 05/01/2021 at 14:570 Comments

I spent some time going through the XMega D manual. One thing I found out was that the actual SPI system isn't going to be the best choice for AVR programming. The issue is that the clock system is designed to go way too fast. The slowest you can make it go is CLKper / 128, which for a 32 MHz system clock is 250 kHz. As an alternative to that, you can instead put the USART into SPI Master mode. In that configuration, you can use the USART baud rate generator to essentially make arbitrarily slow clocks. If there's a downside there, it's that the highest clock speed available is 2 MHz, but that's fine. By setting the USART0 and SPI bits in the REMAP register for the port, you can force the USART to be pin-compatible with the SPI system. But since the USART is going to wind up being the only peripheral used - whether in synchronous, asynchronous or SPI mode - it's possible to revisit this in the hardware later so that it won't be necessary.

Discussions