Digistump Forums

The Digispark => Digispark Pro Support => Topic started by: Pinguinsan on February 02, 2017, 04:11:13 pm

Title: Is the UART/LIN of the Attiny167 (Pro) implemented as Serial or Serial1?
Post by: Pinguinsan on February 02, 2017, 04:11:13 pm
Hello. I've just purchased 12 Digispark Pros' in the hope of communicating with a LIN transceiver via the onboard ATTiny167 UART. Is the UART attached to PA0/PA1 implemented as Serial or Serial1 in this Arduino core implementation? I do not want to use a SoftwareSerial solution, as it will not be as reliable. I am struggling to find information regarding this issue. I also do not want to use the USB+/- pins. Thank you.
Title: Re: Is the UART/LIN of the Attiny167 (Pro) implemented as Serial or Serial1?
Post by: PeterF on February 02, 2017, 05:38:49 pm
I don't know if you've come across the pinout diagram for the Digispark Pro (http://digispark.s3.amazonaws.com/DigisparkProDiagram2.png) yet... if not, keep it handy ;). Unfortunately, it will confuse on this point as the UART is not Serial1, it is Serial :-O

In other words, pin 6/PA0 is Serial RX, and pin 7/PA1 is Serial TX. I don't know why it references Serial1 in the diagram... maybe it was different in an earlier version of the core?
Title: Re: Is the UART/LIN of the Attiny167 (Pro) implemented as Serial or Serial1?
Post by: Pinguinsan on February 02, 2017, 06:12:13 pm
Thank you very much for your quick reply, Peter! I did indeed stumble on that diagram, but it was actually what caused my confusion to start with! I noticed in the *pins.h variant file for the Pro that USE_SOFTWARE_SERIAL was defined, which in turn disables most of HardwareSerial.cpp, so I was certainly confused. As well, I did not understand why the native USB on the chip would be used with Serial, and the other pins would be Serial1, but it sounds like maybe that was a misprint, from your description. And on further inspection, the top of that image does say "The Official BETA", so perhaps it was an older revison. But anyway, I'm rambling now. I will try PA0/PA1 with an 5V FTDI cable tomorrow, thank you very much again for clearing that up for me. Cheers!
Title: Re: Is the UART/LIN of the Attiny167 (Pro) implemented as Serial or Serial1?
Post by: PeterF on February 02, 2017, 11:12:21 pm
No worries. Let me know how you go. I'd just tried it with a Digispark Pro I had lying around when I'd posted earlier, and the ASCIItable example sketch with the Arduino IDE (which uses Serial @ 9600baud) worked fine out of the box. I suspect however from a quick look through the files that a Tiny specific SoftSerial implementation is used, however, as TinySoftwareSerial appears to be used instead of HardwareSerial when the USE_SOFTWARE_SERIAL define is set. However, I may just be was confusing myself as according to this post (http://digistump.com/board/index.php/topic,1596.msg7565.html#msg7565) the Digispark Pro should be using a hardware serial implementation instead of a software one!  ??? After some more reading: Er... USE_SOFTWARE_SERIAL is defined as '0', which is disabled ;)

You may also find the comment after that by RC Navy (http://digistump.com/board/index.php/topic,1596.msg7574.html#msg7574) interesting, as he gives a good discussion into the HardwareSerial and SoftwareSerial on the Digispark Pro.