Pages: 1 ... 3 4 [5] 6 7 ... 14   Go Down
Author Topic: SoftwareSerial with ATTiny84 using ATtiny library  (Read 45023 times)
0 Members and 1 Guest are viewing this topic.
Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 200
Posts: 12782
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello rudolf48,

I tried the KnockBang protocol, but I got the error message from the compiler :
  warning: TinyDebugKnockBang.h: No such file or directory

You put the files in the wrong location.

Quote
Also copying them to the "hardware/cores/tiny" folder did not help.

Don't put them there.

Quote
I had copied before both files to the "library" folder.

"library" or "libraries"?  Under a folder named "TinyDebugKnockBang"?

The correct location is...

{Arduino Sketch Root}\libraries\TinyDebugKnockBang\
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello Coding Badly,

Thank you for the hint with the library path. That was my fault.
Because I forget so quickly, I documented that KnockBang setup in my wiki.
  http://www.rudiswiki.de/wiki9/AVRTinyISP#KnockBang_serial_protocol

Please take a time to read the details, if I have all necessary documented.

Regards, Rudolf
Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 200
Posts: 12782
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello rudolf48,

This...

Quote
The application program must have the following statements for debug output, for example:

Code:
# declaration
#include <TinyDebugSerial.h>
TinyDebugSerial mySerial = TinyDebugSerial(); // PB1 = TX pin

# in function setup()
  mySerial.begin( 9600 );    // for tiny_debug_serial

# in function loop()
  mySerial.println( "Testing...");  // debug output

...is not necessary.  The Tiny Core already includes an instance of TinyDebugSerial named Serial.  This should work...

Code:
# in function setup()
  Serial.begin( 9600 );    // for tiny_debug_serial

# in function loop()
  Serial.println( "Testing...");  // debug output
Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 200
Posts: 12782
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


I think the Knock-Bang example can be reduced to this...

Code:
#define KNOCK_BANG 1
#include <TinyDebugKnockBang.h>

#ifdef KNOCK_BANG
#define Serial Debug
#endif

..then you just use Serial...

Code:
// the setup routine runs once when you press reset:
void setup() {               
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT); 
  Serial.begin( 9600 );
}

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);
  Serial.println( "Testing...");  // debug output
}
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello Coding Badly,

Thank you very much for improving my example C-code. Probably I will never reach this level  smiley-sad
  http://www.rudiswiki.de/wiki9/AVRTinyISP#KnockBang_serial_protocol

I am answering so late, because I struggled a day finding a loose contact on my breadboard  smiley-sad

But now I have a compact and clever debugging tool for the ATtiny's.

Best regards, Rudolf
Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 200
Posts: 12782
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


Very nice.  Thank you for the follow-up.
Logged

Denmark
Offline Offline
Edison Member
*
Karma: 35
Posts: 1058
Happy Hobbyist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Nice write-up rudolf.

My thoughts about Serial Relay and Knockbang.

I think the buty about Serial Relay is that you have two way communication. This makes the tiny environment look and feel almost like an Arduino.

If you want to utilize this feature you have to use SoftwareSerial, atleast that is my understanding.
On the other hand I can see the advantage of using the TinyDebugSerial: You can take a Arduino sketch an compile it for a tiny without midifying the Serial.print() statements.
Logged

Denmark
Offline Offline
Edison Member
*
Karma: 35
Posts: 1058
Happy Hobbyist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Just a follow up on a previous post:

I have tried using KnockBang on a Attiny13, with no luck

I get this error:

Code:
In file included from tiny_knockbang.cpp:1:
D:\arduino-1.01\arduino-1.0.1-windows (1)\arduino-1.0.1\libraries\TinyDebugKnockBang/TinyDebugKnockBang.h:55: error: 'fstr_t' does not name a type

Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 200
Posts: 12782
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


Delete that line (#55) from TinyDebugKnockBang.h ...
https://github.com/Coding-Badly/TinyDebugKnockBang/blob/master/TinyDebugKnockBang.h#L55
Logged

Denmark
Offline Offline
Edison Member
*
Karma: 35
Posts: 1058
Happy Hobbyist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

After deleting line 55, I get this error:

Code:
D:\arduino-1.01\arduino-1.0.1-windows (1)\arduino-1.0.1\libraries\TinyDebugKnockBang/TinyDebugKnockBang.h:152: error: expected ',' or '...' before '*' token
Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 200
Posts: 12782
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


Which core are you using?
Logged

Denmark
Offline Offline
Edison Member
*
Karma: 35
Posts: 1058
Happy Hobbyist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I am using smeezekitty's core:

http://arduino.cc/forum/index.php/topic,89781.0.html

http://sourceforge.net/projects/ard-core13/
Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 200
Posts: 12782
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


The core is missing this...
Code:
class __FlashStringHelper;
#define F(string_literal) (reinterpret_cast<const __FlashStringHelper *>(PSTR(string_literal)))

I suggest adding it to WProgram.h.

You may have to also add this to the top...
Code:
#include <avr/pgmspace.h>
Logged

Denmark
Offline Offline
Edison Member
*
Karma: 35
Posts: 1058
Happy Hobbyist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks,

I added these to the WProgram.h, which gave another error:

Code:
D:\arduino-1.01\arduino-1.0.1-windows (1)\arduino-1.0.1\libraries\TinyDebugKnockBang/TinyDebugKnockBang.h:156: error: 'DEC' was not declared in this scope

So I added #include "print.h" in the WProgram.h , and now it compiles and uploads.

When I open the serial monitor (19200 baud) and type a ! I get this error:

--- Knock-Bang fault: 15 ---

I was thinking it maybe had something to do with the clock speed which was 128kHz, so I tried at 9,6 mHz and got this error:

--- Knock-Bang fault: 11 ---
i get the correct respons from the serial monitor, when I use  @,# and !

« Last Edit: December 11, 2012, 08:37:30 am by Erni » Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 200
Posts: 12782
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

So I added #include "print.h" in the WProgram.h , and now it compiles and uploads.

Excellent.

Quote
I was thinking it maybe had something to do with the clock speed which was 128kHz,

The minimum supported clock speed is 1 MHz.  If I can remember, I'll put a check in the header file.

Quote
so I tried at 9,6 mHz and got this error:

--- Knock-Bang fault: 11 ---
i get the correct respons from the serial monitor, when I use  @,# and !

fault_timeout_knock ... In the interrupt service routine, a knock was not detected within the time limit.

Other then a wire, is anything connected to MISO?

Try adding a 10K or 4.7K or 1K pullup resistor to MISO.  And/or, if the wire on MISO connecting the programmer to the target is longish, try a shorter and/or fatter wire.
« Last Edit: December 11, 2012, 01:58:13 pm by Coding Badly » Logged

Pages: 1 ... 3 4 [5] 6 7 ... 14   Go Up
Jump to: