Monday, April 22, 2013

Added TinyDebugSerial to attiny85

One of the challenges of 8-pins attiny85 is that we do not have Serial Monitor debugging after flashing the hex into the IC. As per my previous blog, without debugging output, we cannot be sure what is happening when the attiny is up and running.

While browsing the arduino forum, I came across this site that wrote about several methods to have serial communications to the attiny. Since I only have CSN & CE pins free when the nRF24L01 is not transmitting, I decide to go with the TinyDebugSerial method of serial output. This method will use the attiny85 PB3 pin and transmit to the Serial-TTL receiver or an Arduino.

You can use a USB-Serial TTL module or an Arduino to receive the serial transmitted by the attiny and only use one pin on the attiny. Since I have an extra USB FTDI to Serial TTL breakout board, I will use this board and also power up the attiny and nRF24L01 using the on-board selectable 5V/3.3V regulator. Choose 3.3V jumper as the nRF24L01 can only take up to 3.8V only.

attiny/nRF24L01 with FTDI BoB
The above image is my prototype with 6-pin ICSP header on top of the attiny85 with connections to the nRF24L01 and TX to the RX of the FTDI. When I am programming the attiny85, I had to remove the nRF24L01 transceiver and Vcc jumper cable from the FTDI as my USBtinyISP is providing power to the attiny85 and prevent the nRF24L01 transceiver from interfering the attiny85 during flashing/programming the chip. Once the USBtinyISP programming is done, I can immediately "see" the output from the USB-FTDI on my console/serial monitor. 

attiny to USB-Serial TTL

The first step is to install the new tiny cores from and compile the codes with the new cores to make it everything is working without the extra codes. Once everything is working fine, I added the following lines to my codes :-

#include <TinyDebugSerial.h>
TinyDebugSerial mySerial = TinyDebugSerial();

// Put this in setup()
  mySerial.begin( 9600 );

// Put this in loop()

  mySerial.print("Sent :");

The rest of the code is at the github repo under libraries/mirf85/examples at the link below.

When I tried to compiled it, I got the following compilation errors due to using an older version of WinAVR on Windows or older avr-gcc on Mac OSX software on the Arduino IDE 1.0.1.

"R_AVR_13_PCREL against symbol `exit' defined in .fini9 section in" 

Here are the links to the fixes and I will not rewrite it here... it have to do with an updated ld file for the avr.

Windows fixes :- Arduino Forum
Max OSX fixes :-  Arduino Forum

Once the above fixes is applied, I was able to see serial output on my USB-Serial on the serial monitor or any terminal program.

Summary Links :-
- Updated github repo
Serial Comms with attiny
Atmel AVR TinyISP
- Attiny cores with TinyDebugSerial
Window fixes for R_AVR_13_PCREL
Mac OSX fixes for R_AVR_13_PCREL

No comments:

Post a Comment


Related Posts Plugin for WordPress, Blogger...