I always wanted to be able to write something like this in my code
debugging_print("working, x=%i", x);
… have that running on the micro-controller and see the debugging output on my computer.
Unfortunately that is not easy – in fact not possible with the standard tools used to work with the ATtiny85. The problem is this: (1) those micro-controllers have too few I/O ports; and (2) most of the programmers (the one I’m using is USBasp) do not offer that kind of communication between the micro-controller and the computer, i.e. there is no 2-way communication.
There are many solutions to that problem and while looking on Internet I found this article http://www.ernstc.dk/arduino/tinycom.html that points to some of them:
- TinyDebugSerial: https://code.google.com/p/arduino-tiny/source/browse/cores/tiny/
- Lightweight Serial Output: http://nerdralph.blogspot.ca/2013/12/writing-avr-assembler-code-with-arduino.html
- TinySoftwareUSART: http://forum.arduino.cc/index.php?topic=255250.0
Since the purpose of The Tinusaur Project is learning I decided to write my own.
To do that I needed:
- Tinusaur Board.
- USBasp programmer – to load the program to the board.
- USB to Serial TTL converter – to transfer the debugging output from the ATtiny micro-controller to the computer.
(mine’s based on Prolific PL2303, not the best choice by the way)
The USB-to-Serial TTL is a device that when connected to the USB port of the computer will look to the operating system like a Serial COM Port. Writing data to that COM port will result in transferring that data through the converter and out to the output pin called TxD – in serial form. It work similarly when receiving data from an external source of signal connected to the RxD pin.
I connected the PB0 of the ATtiny85 to the RxD of the USB-to-Serial TTL and did some experiments. Soon I realized that the timing of the signals was critical for this to work and I needed better way to compose the serial data.
Reference Character Generator
First thing – a serial data character generator that I can use as reference – and what could be better than an original USB-to-Serial converter.
I also needed a software that will generate sequence of test characters that I would use as a test signal. First I though of writing a simple Java program that will send the data to the COM port but then I found an application on Internet that does that already – COMStressTest from AGG Software at http://www.aggsoft.com/com-port-stress-test.htm.
I specified my testing data in the “Data source” tab as an external file.
The best testing sequence in this case would be string of “U” characters. This is because the generated signal will consist of equal LOW and HI intervals known also as square wave signal.
ASCII "U" = 0x55 = 01010101
To look more precisely at the signal form and parameters I used an oscilloscope – mine is DSO Quad from Seeedstudio at http://www.seeedstudio.com/depot/DSO-Quad-4-Channel-Digital-Storage-Oscilloscope-p-736.html.
The signal should look like this …
That’s all for now.
The next step will be to write some code for the ATtiny that will generate the same sequence – all “U” character and try to make it exactly the same as the reference one.
IMPORTANT: All the tests were done with the default settings for the serial COM port which are 9600 bps, 8 bits of data, no parity check and 1 stop bit. This is sometimes denoted as 9600 / 8-N-1 configuration.
NEXT PART: OWOWOD – One Wire / One Way Output for Debugging the Tinusaur (Part 2)
All the OWOWOD source code is available at https://bitbucket.org/tinusaur/owowod/src.
2 thoughts on “OWOWOD – One Wire / One Way Output for Debugging the Tinusaur (Part 1)”
I have error by compiling any of files
owowod_test1, owowod_test2, owowod_test3, owowod_test4
line2: syntax error: unexpected end of file
MAKE.EXE *** [sizebefore] Error 258
I use WinAVR 20100110 4.3.3
Ravil, the WinAVR uses very an old version of the GCC AVR SDK.
You should use the latest SDK – you could find it within the Arduino installation folders or download it directly from Atmel/Microchip website.