User Tools

Site Tools


digispark:tutorials:debugging

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
digispark:tutorials:debugging [2013/05/04 15:58]
RC Navy [One Wire Soft Serial Debugging]
digispark:tutorials:debugging [2016/06/09 12:03] (current)
Line 48: Line 48:
 [[digispark:​tutorials:​lcd|LCD Shield Kit Tutorial]] [[digispark:​tutorials:​lcd|LCD Shield Kit Tutorial]]
  
-===== One Wire Soft Serial Debugging =====+===== Bi-directional ​Serial Debugging ​with a single I/O =====
  
-Since the last version of <​SoftSerial>​ library (may 2013), <​SoftSerial>​ is an alternative for debugging Digispark just using a single I/O. By declaring a <​SoftSerial>​ object with the __same__ pin for Tx and Rx: it's possible to use a half duplex (request/​response) software serial port using a __single__ I/O.+If you didn't plan to use DigiUSB in your final sketch, the following proposed alternative consumes less pin and  program memory than USB.\\ ​Since the last version of <​SoftSerial>​ library (may 2013), <​SoftSerial>​ is an alternative for debugging Digispark just using a single I/O.\\ By declaring a <​SoftSerial>​ object with the __same__ pin for Tx and Rx: it's possible to use a half duplex (request/​response) software serial port using a __single__ I/O
 +The external interface is composed of 2 resistors and a regular diode (See below).\\ This approach allows to use the built-in Serial Monitor of the arduino IDE.\\ Please, note this solution requires a native RS232 port (rare today) or a RS232/USB adapter on the development PC.
  
-__Usage__:+==== How to use this debugging capabilities?​ ====
  
 In your sketch, declare a <​SoftSerial>​ object with the same pin for Tx and Rx as depicted below: In your sketch, declare a <​SoftSerial>​ object with the same pin for Tx and Rx as depicted below:
  
-<​code>​ +=== Simple example of sketch ​===  
-/* +<code c>
-Hardware wiring: +
-=============== +
-                         ​SERIAL ONE WIRE +
-                         ​DEBUGGING CABLE +
-            ___________________/​\__________________ +
-           / ​                                      \ +
-                                              ____ +
- ​.--------. ​                                 |    \ +
- ​| ​   GND |--------------------------------+---o5 ​ \ +
- ​| ​       |                           ​47K ​ | |   9o | +
- ​| ​       |                        .--###​--'​ | o4   | +
- ​| ​ DEBUG |                  4.7K  |         ​| ​  8o | +
- |  TX_RX |-------------------###​--+--|<|------o3 ​  ​| ​   ---To regular RS232 SubD 9 pins Male of PC or Serial/USB adapter +
- ​| ​  ​PIN ​ |        ^               | 1N4148 ​ |   7o | +
- ​| ​       |        |               '​-----------o2 ​  | +
- '​--------' ​       |                         ​| ​  6o | +
-  ATtiny85 ​      ​Single ​                     | o1  / +
- ​(Digispark) ​     I/O                        |____/ +
-                                          SubD 9 pins +
-                                            Female +
-*/+
 #include <​TinyPinChange.h>​ #include <​TinyPinChange.h>​
 #include <​SoftSerial.h>​ #include <​SoftSerial.h>​
Line 99: Line 79:
   {   {
     MyDbgSerial.txMode();​     MyDbgSerial.txMode();​
-    MyDbgSerial.print(F("​Received: "​));​MyDbgSerial.write(MyDbgSerial.read());​MyDbgSerial.print(F("​\n"​));​+    MyDbgSerial.print(F("​\nReceived: "​));​MyDbgSerial.write(MyDbgSerial.read());​MyDbgSerial.print(F("​\n"​));​
     MyDbgSerial.rxMode();​     MyDbgSerial.rxMode();​
   }   }
 } }
 +</​code>​
 +=== Hardware wiring ===
 +<​code>​
 +                        SERIAL SINGLE I/O
 +                         ​DEBUGGING CABLE
 +            ___________________/​\__________________
 +           / ​                                      \
 +                                              ____
 + ​.--------. ​                                 |    \
 + ​| ​   GND |--------------------------------+---o5 ​ \
 + ​| ​       |                           ​47K ​ | |   9o |
 + ​| ​       |                        .--###​--'​ | o4   |
 + ​| ​ DEBUG |                  4.7K  |         ​| ​  8o |
 + ​| ​ TX_RX |-------------------###​--+--|<​|------o3 ​  ​| ​   ---> To regular RS232 SubD 9 pins Male of PC
 + ​| ​  ​PIN ​ |        ^               | 1N4148 ​ |   7o |         or to RS232/USB adapter
 + ​| ​       |        |               '​-----------o2 ​  |
 + '​--------' ​       |                         ​| ​  6o |
 +  ATtiny85 ​      ​Single ​                     | o1  /
 + ​(Digispark) ​     I/O                        |____/
 +                                          SubD 9 pins
 +                                            Female
 </​code>​ </​code>​
  
-If you didn't plan to use DigiUSB in your sketch, this alternative consumes less pin than USB and less program memory. +=== Connection between the Digispark ​and the PC === 
-Plug the "​Serial ​One Wire Debugging Cable " to a native RS232 port or a RS232/USB adapter ​to your development PC. On the PC, open your favorite Terminal application at 38400,​n,​8,​1:​ HyperTerminal,​ Teraterm (Windows) or Minicom, GtkTerm (Linux) and CoolTerm for MAC does the trick.+Plug the "​Serial ​Single I/O Debugging Cable " to a native RS232 port or to a RS232/USB adapter ​on your development PC.
  
-Trick  to be less intrusive: use a "​high" ​data rate (38400 is fine): less time wasted in ISR and for transmitting each character.+=== Built-in IDE Serial Monitor or external Terminal? === 
 +With this approach, the regular serial monitor of the arduino IDE can be used. In the IDE, just select the RS232 port through the Tools->​Serial Port menu. Then, adjust ​data rate and line terminator ​(if any), you can use the serial console as usual. 
 +In this case, you do not need any external Terminal.\\ If you prefer using an external Terminal, on the PC, open your favorite Terminal application at 38400,n,8,1HyperTerminal,​ Teraterm (Windows) or Minicom, GtkTerm (Linux) ​and CoolTerm (MAC) does the trick.
  
 +
 +__Note__:
 +  * Trick  to be less intrusive: use a "​high"​ data rate (38400 is fine) -> less time wasted in ISR and for transmitting each character.
 +  * You can still upload your sketch modifications through the USB interface whilst the additionnal serial port is selected as Serial port in the IDE.
 "​Vintage"​ serial interfaces are not dead! :-) "​Vintage"​ serial interfaces are not dead! :-)
 +
 +[[http://​p.loussouarn.free.fr/​partage/​arduino/​Libs4Digi_1io_Debug.zip|Download here the related libraries]]
digispark/tutorials/debugging.1367708298.txt.gz · Last modified: 2013/05/04 15:58 by RC Navy