ATTiny26: Using USI as UART // Issue
2004-12-04 by David D. Rea
Hi Everyone- First post here, so I humbly beg your pardon if this topic has been discussed previously. I did a quick search through the message archives and didn't turn anything up. I'm working with the following setup: - ATTiny26 @ 1MHz - WinAVR for C development - ATAVRISP I'm trying set up a simple means to get debug messages out of the micro. Just dump the values of some ADC samples, etc. I found the Atmel appnote regarding using the USI as a UART via Timer0 and the USI overflow interrupt. Sounded pretty cool, but their example with both Tx/Rx and buffering was overkill for my needs. All I really need is a sendchar function. So I figured I'd just implement their concept on my own, only the Tx side. Besides, their example was written in IAR C, and I'm working with the GNU avr-libc, so in the time it would have taken to port it, I figured I could implement it myself. Got quite a ways along with it, but I've got one problem (thus far at least). The Timer0 counter register needs to be seeded with a value to set the baud rate after each bit time. Got that working great, but as soon as I enable the USI by setting its clock source to be the Timer0 overflow, it up and clears the interrupt flag and I've got no Timer0 ISR to seed the timer any more! :( The appnote doesn't seem to address this; it's written (evidently) under the assumption that Timer0 can both clock the USI *and* fire off its own ISR. Which must be the case... I'm just missing it somewhere in my implementation. Has anyone run across this? Or something similar? Thanks in advance, Dave Upstate NY