SoftwareSerial with ATTiny84 using ATtiny library

Hi All,

Does anyone know if this can be used with something else that uses the MISO/MOSI? I need to debug an ATTiny84 connected to an NRF24L01+ transmitter, but I just get knock bang faults when trying to debug. I assume its conflicting on the MISO/MOSI pins.

Is there an alternative? Can the TinyDebugKnockBang use a different pin? (I understand I would have to move the pin once the programming is done, but its better than no debug!)

Thanks

Kihon

Hello,

kihon:
Can the TinyDebugKnockBang use a different pin?

Yes.

The pin assignment for the ATtiny84 is here...
http://code.google.com/p/arduino-tiny/source/browse/TinyDebugKnockBang.h?repo=debugknockbang#55

Or, you could assign values to the KBS_* macros at an earlier point in the compilation...
http://code.google.com/p/arduino-tiny/source/browse/TinyDebugKnockBang.h?repo=debugknockbang#108

On the TinyISP side, enable RELAY_KNOCK_BANG_USE_ALTERNATE_PIN in _TinyISP_BuildOptions.h ...
http://code.google.com/p/arduino-tiny/source/browse/_TinyISP_BuildOptions.h?repo=isp#42

The alternate pins on 328 processors is digital pin 7 (PD7)...
http://code.google.com/p/arduino-tiny/source/browse/TinyISP_SelectBuildOptions.h?repo=isp#200

Hi, I´m currently trying to get Tiny Debug Knock-Bang to work with my Attiny 85 @ 8mhz. I followed the guide from page 2 #33 and succeeded in getting Serial Monitor response to "!" . Then i followed on to the Knock-Bang debug but i cant get it to work even though my baud rate in Serial Monitor was set to 19200. When the capacitor between gnd and reset isnt set my arduino (328 nano) led blinks every time i change the baud rate in the monitor. Totally have no clue what is going on, i can compile the example sketch and upload it but i can´t read my tiny :frowning: I even tried it with 1 mhz makes no difference.
The only option i have left is using Serial and switching pins all the time but it works.

Now i´ve gotten a way bigger problem, flashed following sketch :

void setup(){
  Serial.begin(9600);
  pinMode( A1, INPUT );  //PB2 (ADC1)  
}

void loop(){
  Serial.println(analogRead(A1));
  delay(100);
}

Now my nano led keeps blinking all the time, the analog read on the CLK pin on the tiny seems to mess up with tinyISP, i can´t upload any more and getting sync errors ( i can see it is being initialized RX/TX on nano blinking shortly). I just need to "reset" or overwrite the progmem of the tiny. What are my options here ?

I don't think the sketch you uploaded to the tiny is the problem.
I just tried to upload your sketch, and afterwards I could upload the blink sketch without problems.

I use TinyISP on a UNO, (and a 10uF capacitor from reset to ground)

Do you have something else connected to the tiny while programming ?

I don´t know i´ve read that using pinmode can cause some problems, i tried flashing arduinoISP and tinyISP again. Somehow i got lucky and the led didn´t blink any more maybe the setting of tinyISP was wrong (buildoptions) and i was able to flash, now i still wanna try tinydebugknockbang. From what i have understood the reply to the ! message is arduino based not tiny based so i kinda didnt figure out how to get a Serial read from my tiny except using Serial and a Serial USB converter (used for programming pro mini).

Yes i have connected a line from pb3 (Serial TX) to RX of my Serial USB converter, even while i Flash since the port is not used. I can definately tell that the blinking only occured when PB2 was connected to D13 ( i guess there was a bug because i used Serial in my programm but had turned the settings to using Knockbang).

Since I wanted to programm differential read and I´m getting strange offset readings (around 1000), i thought maybe because I use Serial. Does the DIDR0 reg set off the ADC ? I am measuring PB4-PB4 and i still get high values even though my DIDR0 reg is --11 1111.
Only when I leave the BIN in ADSCRB 0 i get 0 as measurement, which should be not true.
Sorry for going offtopic here, maybe u tried smth. similar and had same issues.

I'm not sure what you're asking about and certainly not in the last section.

To get started with Knockbang, here is what I do:

In _TinyISP_BuildOptions_h i put these lines:

#define RELAY_SERIAL_ENABLED  0
#define RELAY_KNOCK_BANG_ENABLED 1

And in TinyISP I comment this:

//#include <SoftwareSerial.h>

Then I upload this sketch to the ATtiny85:

#include <TinyDebugKnockBang.h>

int x=0;

void setup( void ) {
  Debug.begin( 250000 );
 }

void loop( void )
{
  Debug.print("Test-");
  Debug.println(x++);
  delay( 1000 );
}

Open the serial monitor @19200 and enter !

More details can be found here:

http://www.ernstc.dk/arduino/tinycom.html

Open the serial monitor @19200 and enter !

It wasn´t clear to me that you have to start the monitor for KnockBang aswell :slight_smile: tyvm

Greetings,
I have a couple of ATtiny2313 chips & I want to burn thr arduino bootloader into it & upload sketches. I have an uno board, a couple of breadboards & jumper wires etc.
I followed This tutorial Programming Attiny2313 with Arduino Uno
& this ATtiny core to setup my IDE Google Code Archive - Long-term storage for Google Code Project Hosting.
In that page the author refers your posts from arduino community http://arduino.cc/forum/index.php/topic,123388.30.html

Need to clarify a few things before I finally burn the bootloader....

  1. What core is the most appropriate? The one that is referred in the tutorial or should I use your github core files? I am using arduino 1.5
  2. Will you please tell me in brief what is serial relay & knockBang protocol?
    I searched google but didn't find anything appropriate. Tried searches...

KnockBang - what is relay knockbang - Google Search

Relay Serial - relay serial - Google Search
Thanking you in anticipation.

I want to burn thr arduino bootloader into

Do you realy want ton use a bootloader ?
If you use a programmer as mentioned in that tutorial, you don't need a bootloader.
Burning bootloader is just a way to set the fuses for the desired clock frequense

I am using arduino 1.5

If you use version 1.5 you will have to make a few changes.

http://forum.arduino.cc/index.php?topic=51984.msg1463698#msg1463698

what is serial relay & knockBang protocol

It is a very smart way to communicate with the t2313. If you use it you don't have to use a external serial/USB converter,
and you don't need to change between programming and serial connection, it is almost like programming an Arduino Uno.

You have to use a special sketch. Use this called TinyISP

https://github.com/Coding-Badly/TinyISP/zipball/master

Instead of the usual ArduinoISP, that is included with the IDE

BTW: I am the author of the page you mentioned:
http://www.ernstc.dk/arduino/2313.htm
If you have any comments, improvements please let me know

Erni:
If you use version 1.5 you will have to make a few changes.

No longer necessary. Tiny Core 1 has been packaged for Arduino 1.5. Both are available on the home page...
http://code.google.com/p/arduino-tiny/

Hello :slight_smile:

Thanks for your response. I was a little bit surprised to find the author here. Thanks for your time & effort that you put in the article to help us. Thanks to Coding Badly too.
I have successfully uploaded sketches to ATtiny2313 by using (Arduino UNO) ArduinoISP & SPI protocol. I used the ATtiny core for arduino1.5

Now the other half. I have a sketch loader circuit (FTDI based breakout board). I want my ATtiny to get burnt using the FTDI chip just like we upload sketches in ATmega328 on BreadBoard.

I want to replace the UNO board by FTDI breakout board (Tx, Rx, RST pin). I did this but IDE says NO USB aavailable. Any help please.
What it TinyISP? Has it something to do with my issue? I have downloaded the coding-badly tinyISP zip file. What should I do now? Thanks for all your support & guidance
cheers.

What it TinyISP?

It is just a replacement for ArduinoISP, with extra features

If you want to use a FTDI board , you will need a bootloader. I haven't heard of any bootloader for the t2313, maybe because of the very small memory :2K Flash, 128 SRAM

I saw that there should be a bootloader for ATtiny85
http://forum.arduino.cc/index.php?topic=203108.0
But the t85 has 4 times as much memory

Thanks for your response. I was a little bit surprised to find the author here. Thanks for your time & effort that you put in the article to help us

You are welcome.

And just to avoid any mistakes.
The Tiny core, TinyISP and so on are developed and maintained by Coding Badly.
Something like that far exceeds my programming skills, I am just a hobbyist

Thanks for your response. Glad to be here in this community
:slight_smile:

Tiny Core 1 has been packaged for Arduino 1.5.

FYI it also works with 1.5.5

Now we can have line numbers, and also info about dynamic memory.
This is the blink sketch on a t85

Sketch uses 804 bytes (9%) of program storage space. Maximum is 8,192 bytes.
Global variables use 11 bytes (2%) of dynamic memory, leaving 501 bytes for local variables. Maximum is 512 bytes.
avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85
avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85

155.jpg

Hi all,

I am trying to get the serial relay to work with an attiny84 and arduino uno. I have had some help from Erni in another thread but now I need som information again.

I have built a "shield" for programming the attiny84 which works excellent. Seven pins are connected to the arduino (incl. a reset capacitor) in standard fashion.

Now I wanted to use the shield to also function using software serial. So I tried ernis code(Communication with Tiny's) with a small modification:

include <SoftwareSerial.h>
 // Attiny84 and TinyISP Serial Relay


const int rx=PA4; //receive pin on attiny pic any; changed from PB1 in ernis code
 const int tx=PA5; //MISO on attiny is also tx

SoftwareSerial mySerial(rx, tx);
 void setup() { 
 mySerial.begin(9600);
 }

void loop() {
 if(mySerial.available()>0){
 mySerial.println(mySerial.read());
 }
 
 mySerial.println("ttt");
 delay(1000);

 }

Above the code (on ernis webpage) it states that "Transmit on Arduino is pin A0" which is consistent with this statement

static SerialRelay RelaySerial( 12, 14 );

in the relaysoftserial.h in TinyISP.

So instead of soldering a new connection on the shield connecting (PB1) to AO I wanted to use PA4 which is already connected to pin 13 on the arduino.
so I change to static SerialRelay RelaySerial( 12, 13); in relaysoftserial.h

The output from serial monitor is this:

þÿ
--- Monitor starting ---
ttt
ttt
ttt
ttt
ttt

which means the transmit from the tiny is working but I also send characters during this which are not getting back.

Suggestions?

So, I used the breadboard style programming and hooked up the rx from arduino to pin 7 and the tx on the tiny to PA7 but no avail.

I checked the the signal from the arduino pin 7 and it is high until I send digits through the monitor, so it seems the attiny does not receive.

Is this a tuning problem? If so, would it no be similarly affecting the transmit from the attiny?

const int rx=PA4; //receive pin on attiny pic any; changed from PB1 in ernis code
const int tx=PA5; //MISO on attiny is also tx

SoftwareSerial mySerial(rx, tx);

You are comingling code that expects Arduino pin numbers with I/O port bit numbers.

http://code.google.com/p/arduino-tiny/source/browse/cores/tiny/pins_arduino.c#162

PB1 is digital pin 1. PA5 is digital pin 5.

Google Code Archive - Long-term storage for Google Code Project Hosting.

PB1 is digital pin 1. PA5 is digital pin 5.

Agreed!

As I tried to state in my second post I now use PA7 on attiny (physical pin 6, digital pin 3) connected to arduino pin 7.

I see how this:

the rx from arduino to pin 7 and the tx on the tiny to PA7

can seem a bit confused.

What I meant was the tx on arduino is assigned pin 7 (in relaysoftserial.h) and the rx on attiny is assigned to PA7.

I will now test all pin positions on the attiny to rule out any assignment error...

How weird...

#include <SoftwareSerial.h>
 // Attiny84 and TinyISP Serial Relay


const int rx=PA7; //receive pin on attiny pic any
 const int tx=PA5; //MISO on attiny is also tx

SoftwareSerial mySerial(rx, tx);
 void setup() { 
 mySerial.begin(9600);
 }

void loop() {
 if(mySerial.available()>0){
   
 mySerial.println(mySerial.read());
 }
 
 mySerial.println("ttt");
 delay(1000);

 }

works on physical pin 10 (digital pin 7, PA3 according to : Google Code Archive - Long-term storage for Google Code Project Hosting.)

Now I'm really confused...

changed to const int rx=7; without moving the connection and it still works.

I guess I should stick to digital pin numbers if I can huh...

I'm afraid that I am to blame for the confusion.

I have corrected the pin names/numbers here

http://www.ernstc.dk/arduino/tinycom.html

You can use this reference sheet to see both digital and analog pinnumbers.


For example physical pin 10 is digital 7 and analog 3
so:
digitalWrite(7,HIGH); will set physical pin 10 (or PA3) high
analogRead(3); will read from physical pin 10 (or PA3)

BTW
PA3 is short for PortA pin3