2Mbps bit-bang UART on a 10Mhz ATtiny13

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Most of the AVR bit-bang UARTs I've written require a minimum of 7 cycles/bit (without unrolling).  Yesterday I had an idea to cut the loop time to 5 cycles, which allows for 2mbps on an AVR clocked at 10Mhz.

I wrote a proof of concept that writes a repeated sequence of the ASCII character set.

https://github.com/nerdralph/ner...

 

I did a limited amount of testing, and in the process I may have found a bug in the CH330N; at 2Mbps it occasionally drops characters on 32-byte boundaries.

 

I have no special talents.  I am only passionately curious. - Albert Einstein

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Many years ago I wrote some code which generated video on an AVR. I used an 8-way unrolled loop which ran at 4 CPU cycles per pixel a total of 12 times to put out 96 pixels. The concept was...

 

OUT VideoPort, R1
LSR R1
NOP
NOP
OUT VideoPort, R1
LSR R1
NOP
NOP
...

It meant you couldn't use 7 of the 8 bits of VideoPort but that didn't matter. On an tiny13 that's a bit of an issue as all the port pins are on the same pin but on a chip with several, often not fully available, ports it works.

 

With the spare 2 cycles per pixel I interleaved all the remaining calculations, effectively giving me two sections of code running in parallel. Keeping track of what the flags were doing was fun!

 

 

#1 This forum helps those that help themselves

#2 All grounds are not created equal

#3 How have you proved that your chip is running at xxMHz?

#4 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand." - Heater's ex-boss

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ralphd wrote:
I did a limited amount of testing, and in the process I may have found a bug in the CH330N; at 2Mbps it occasionally drops characters on 32-byte boundaries.

Or did you find the limitation of low speed USB? (1.5Mb/s)