Another software UART on ATtiny13
Hello to all habroyuzery. More recently, comrade Himura published his UART article in ATtiny13 or How to output data from MK for 52p , and then I remembered that I have, besides previous developments on this topic, namely the Three-channel UART ADC on ATtiny13 , there is something else, some of which I cut out from a rather interesting project Happy Christmas and Happy New Year wishes from Attiny13 , there is also a software UART, both reading and sending, and something else on SPI, in general I recommend to look at everyone who is interested, though the resource is English.
Here is a video of work:
Having cut off everything that is superfluous for me from the code of Vinod.S , it turned out:
Source code
#define F_CPU 9600000
#include
#include
#define SOFT_TX_PIN (1<>= 1;
while (!(TIFR0 & (1 << OCF0A)));
TIFR0 |= 1 << OCF0A;
}
SOFT_TX_PORT |= SOFT_TX_PIN;
while (!(TIFR0 & (1 << OCF0A)));
TIFR0 |= 1 << OCF0A;
}
Arduino IDE swallowed it without any problems:
All this takes 470 bytes, that is, less than half of the ATtiny13 memory, you can still program a lot if you skillfully use the resources of the microcontroller.
As you can see, the character set Hello Habr, I'm ATtiny 13 is displayed using the uart_print ("...") function ; and the value of variables, for example, let the variable be called value, then the output to the content line will be carried out using the function num_to_str (value, 4); where 4 is the number of digits, in this case, you can display a value from 0 to 9999. The lines uart_print ("\ r \ n"); finish the line when outputting to UART and switch to a new one, similar to the Enter button on the keyboard.#define SOFT_TX_PIN (1 <
And finally - ATtiny13 is clocked from the internal RC chain tuned to the frequency of 9.6 MHz, the divider by 8 is disabled, this is set by the ff bit lf 0x7A .
The speed of the UART is 115200 baud.
And finally, the photo shoot:
So that the pictures do not disappear.
So that the pictures do not disappear.
Links:
UART in ATtiny13 or How to display data from MK for 52r;
Three-channel UART ADC on ATtiny13;
Happy Christmas and Happy New Year wishes from Attiny13 ;
ATtiny13 firmware and programming using Arduino (updated);
All my publications .
PS If the microcontroller is heated to ~ 60 degrees, then garbage will start coming in, checked personally, but this is simple given the price of ATtiny13.