I want to use the Universal Serial Interface (USI) in an ATtiny2313, in three-wire mode, specifically SPI mode 0. It'll be operating as master, and only concerned with data output. There are three options for clocking the interface: external, software, or Timer0 overflow. The examples given in the datasheet use software clocking. I can probably make that work, by inserting NOPs to achieve the clock rate I want. But the Timer0 option seems more elegant. Wondering if anyone has used that or can point me to a resource.
I have a couple questions that I can't find answers to in the datasheet or elsewhere.
-
The datasheet says SPI modes 0 and 1 are supported, but I'm not clear whether that applies to all of the clocking options. There is only one setting for the software (USICLK) strobe option, and one for the Timer0 overflow option. Should I assume these are SPI mode 0?
-
When using the Timer0 clock option, what stops the clock? I assume the timer keeps running. Seems like some mechanism would be needed for the USI module to stop clocking the USCK pin once a byte is sent. I could see stopping the clock when the USIOIF bit in the USISR register gets set, but the datasheet doesn't mention anything like this. So I'm wondering whether I have to do something to stop the clock?
I'm using WinAVR and am kind of new to this level, but have had some success with Arduino. Thanks in advance!