Serial + Wire on attiny25 #704
Replies: 4 comments 3 replies
-
Maybe |
Beta Was this translation helpful? Give feedback.
-
Wire by itself seems to work. This just reads AAAA on the master, even though my scope thinks it's messed up I2C.
Serial by itself... kinda? Without Wire and without changing the txbit it works.
|
Beta Was this translation helpful? Give feedback.
-
It seems that most of the errors are just it running out of memory. |
Beta Was this translation helpful? Give feedback.
-
Sorry, I thought I replied The serial portis a software serial implementation. That means it is counting clock cycles to receive and transmit characters, and has to disable interrupts while doing so. This is much more of a problem since the chip also has a crappy USI instead of real TWI - although as a slave, the USI can receive data if it's busy as the first bits come in (unlike software serial), but unlike real wire, it uses cycle counting and a software strobe to clock the USI (they were too cheap to include a clock generator in the USI - they claim the U stands for universal, but I think "unwieldy" or "unfortunate" better describes it. Essentially all it does for you is clock data in and out, but you provide the clock with a software strobe x_x While recently fixing some issue or another in Wire for 2.0.0-dev, i was struck by the contrast with the modern AVR TWI module, which when generating the clock, waits for the pin to register as high before starting the timer for the high period..... (the slow rise time is a major limiting factor in I2C, since SPI isn't open drain, it can reach much higher speeds. open drain works only up to about 1 MHz if you really try, while serial can and is used at speeds up to 6 mbit (not on AVRs generally, though an AVR DB with extended temperature range can function at 48 MHz with an external clock at room temp, twice it's rated speed.) and SPI can reach 80 MHz and is the de-facto standard for microcontrollers that use external instead of internal flash (it also has been extended to use 4 data lines in some cases, taking over the other pins on the memory - that's how the ESP8266 and ESP32's are able to perform decently despite having everything on an external SPI flash chip - they generally use at least 2 and often 4 of the pins (DIO, and QIO mde), with the chip clocked at like 40 MHz |
Beta Was this translation helpful? Give feedback.
-
I have this really simple program that talks to a sensor over UART and can be read over I2C.
It compiles just fine, but as far as I can tell, SDA and TXD are both on PB0.
I tried using
SoftwareSerial
but it uses too much space.Is there any way I can disable more stuff to save space, or a way to move the TXD pin elsewhere?
I'm fine with manually hacking some headers, or other more low-level hacks.
Beta Was this translation helpful? Give feedback.
All reactions