Pages: 1 ... 9 10 [11] 12 13 14   Go Down
Author Topic: SoftwareSerial with ATTiny84 using ATtiny library  (Read 38928 times)
0 Members and 1 Guest are viewing this topic.
Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 176
Posts: 12286
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

That actually uses SoftwareSerial for the relay.  Would you prefer one of the other USARTs like Serial1?

Yes, I noticed that.  But isn't why you are using SoftwareSerial because you can direct it to the MISO pin?

The first version of TinyISP was made for the m328 processor when Knock-Bang did not exist.  Serial was the only way to send debugging information.  At that point it made sense to use SoftwareSerial with MISO as the RX pin.

The new idea is to use Knock-Bang for debugging and Serial for data.  As I port TinyISP to other processors I have always used a USART if I could. 

Quote
If you use the USART then you would have to wire additional connections from the target?

Well, one extra connection.

Quote
SoftwareSerial seems to be working okay, what would be the benefits of using a USART? More speed options? Better accuracy?

Yes and yes.

With the new interrupt driven Serial, there is also a high probability of dropped data.  Using a USART for Serial Relay eliminates that problem.
Logged

Wahiawa, Hawaii
Offline Offline
God Member
*****
Karma: 27
Posts: 582
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You're not using a capacitor to disable auto-reset?

Yes, I didn't think I needed to disable auto-reset for Serial Monitor mode, but I guess that makes sense.  (After all I did not have to disable auto-reset for ISP programming.)

Out of habit, I exit Monitor when I finish but doing that should not actually be necessary.  There is code in TinyISP that automatically switches from Monitor to Programmer.
Okay, I didn't know about that, Great feature!
So when I exit Monitor mode, it keeps on running after I close Serial Monitor, until I try an upload using programmer or burnbootloader?

Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 52
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Did you remember to Burn Bootloader so the target is actually running at the correct speed?

yes.
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 176
Posts: 12286
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


The fault codes are here... https://github.com/Coding-Badly/TinyISP/blob/master/KnockBangReceiver.cpp#L285

0x11 is fault_timeout_knock which occurs when the pin-change interrupt fires, a knock is detected, but the knock duration is (way) too long.  Loose wire, target at the wrong speed (running at 1 MHz; sketch built for 8 MHz), or the programmer is running significantly faster than 16 MHz.

0x04 is fault_no_knock which occurs when the pin-change interrupt fires and no knock is detected.  Loose wire, target at the wrong speed (running at 8 MHz; sketch built for 1 MHz), or side-effect of a previous failure.

0x13 is fault_timeout_sample_0 which occurs when the first timing mark is not detected.  Loose wire, target running at the wrong speed, or side-effect of a previous failure.
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 176
Posts: 12286
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, I didn't think I needed to disable auto-reset for Serial Monitor mode, but I guess that makes sense.  (After all I did not have to disable auto-reset for ISP programming.)

Wow.  You are actually able to program a target with a 10 second bootloader time-out?

Your experience will be greatly improved by disabling auto-reset!

Okay, I didn't know about that, Great feature!

Thanks.

Quote
So when I exit Monitor mode, it keeps on running after I close Serial Monitor, until I try an upload using programmer or burnbootloader?

Correct.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 52
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

0x11 is fault_timeout_knock which occurs when the pin-change interrupt fires, a knock is detected, but the knock duration is (way) too long.  Loose wire, target at the wrong speed (running at 1 MHz; sketch built for 8 MHz), or the programmer is running significantly faster than 16 MHz.

0x04 is fault_no_knock which occurs when the pin-change interrupt fires and no knock is detected.  Loose wire, target at the wrong speed (running at 8 MHz; sketch built for 1 MHz), or side-effect of a previous failure.

0x13 is fault_timeout_sample_0 which occurs when the first timing mark is not detected.  Loose wire, target running at the wrong speed, or side-effect of a previous failure.

my bootloader/sketch speeds match and i doubt there's a loose wire as they work fine for ArduinoISP and TinyISP. (i assume you mean 50-53?) and the Mega2560r3 is running at stock 16MHz. do you think i need to use tinytuner or edit the fuses somehow?

as far as wiring goes, we are just using MISO/MOSI/SCK/RESET with a USB cable from mega to pc as you would for ISP'ing, and not TX/RX with a USB UART or something?
« Last Edit: June 17, 2013, 03:55:31 pm by sej7278 » Logged

Wahiawa, Hawaii
Offline Offline
God Member
*****
Karma: 27
Posts: 582
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Wow.  You are actually able to program a target with a 10 second bootloader time-out?

Your experience will be greatly improved by disabling auto-reset!
When burning bootloader or Upload using programmer, the IDE appears to be using the stk500v1 protocol (for Arduino as ISP) which avoids invoking the auto-reset on the Mega2560 board.

But I guess I will still need to disable auto-reset for Serial Monitor use.  This could be avoided also if the Mega2560 bootloader did something similar to Optiboot, where it will skip out of bootloader if the wrong baud rate is detected?
« Last Edit: June 17, 2013, 05:30:15 pm by hiduino » Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 176
Posts: 12286
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

as far as wiring goes, we are just using MISO/MOSI/SCK/RESET with a USB cable from mega to pc as you would for ISP'ing

Anything extra connected to MISO?  LED?  SPI device?
Logged

Wahiawa, Hawaii
Offline Offline
God Member
*****
Karma: 27
Posts: 582
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I often use a LED to make sure the sketch running at the expected clock rate.

Try this:
Code:
#include <TinyDebugKnockBang.h>

int led = 3;

void setup( void )
{
  Debug.begin( 250000 );
  pinMode(led, OUTPUT);
}

void loop( void )
{
  digitalWrite(led, HIGH);
  delay(1000);             
  digitalWrite(led, LOW);   
  delay(1000);

  Debug.println( F( "Caitlin! " ) );
//  delay( 1000 );
}

Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 52
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Anything extra connected to MISO?  LED?  SPI device?

yes that's it - i've got a resistor and led coming out of pin 6 on the tiny, if i remove them, knockbang works!

however if i'm doing anything useful in my sketch (some counting, analogWrite, random, delay....) knockbang seems to sit there doing nothing, gets stuck at monitor startin.....
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 176
Posts: 12286
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

however if i'm doing anything useful in my sketch (some counting, analogWrite, random, delay....) knockbang seems to sit there doing nothing, gets stuck at monitor startin.....

Are you asking for helping?  Or did you just need a whine to vent some frustration?
Logged

Wahiawa, Hawaii
Offline Offline
God Member
*****
Karma: 27
Posts: 582
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The first version of TinyISP was made for the m328 processor when Knock-Bang did not exist.  Serial was the only way to send debugging information.  At that point it made sense to use SoftwareSerial with MISO as the RX pin.

The new idea is to use Knock-Bang for debugging and Serial for data.  As I port TinyISP to other processors I have always used a USART if I could. 

That sounds interesting.  So Knock-Bang will continue to use MISO for debugging  and you would also relay Serial via the USART? They both show up on Serial Monitor?  Are you also implying two way with Serial?

Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 176
Posts: 12286
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

This could be avoided also if the Mega2560 bootloader did something similar to Optiboot, where it will skip out of bootloader if the wrong baud rate is detected?

I have an Uno with the framing-error-quick-escape feature.  I had problems getting it to work as a programmer.  The capacitor makes a significant positive difference.  It is worth the 10 cent investment.   smiley-wink
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 176
Posts: 12286
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

That sounds interesting.  So Knock-Bang will continue to use MISO for debugging  and you would also relay Serial via the USART?

Yes.  (With the addition that an alternate pin can be used for Knock-Bang if MISO is otherwise needed.)

Quote
They both show up on Serial Monitor?

Yes.

Quote
Are you also implying two way with Serial?

Yes.

While I have not tested it, that is the way it should work now.
Logged

Wahiawa, Hawaii
Offline Offline
God Member
*****
Karma: 27
Posts: 582
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have an Uno with the framing-error-quick-escape feature.  I had problems getting it to work as a programmer.  The capacitor makes a significant positive difference.  It is worth the 10 cent investment.   smiley-wink

Not to beat this subject dead, but I've been using an Uno R3 without the capacitor and no problems with TinyISP or ArduinoISP.  The bootloader escape seems to work fine on the Uno R3.  It's not a problem to use the capacitor, but it's a little hassle to get it to contact into the headers good or otherwise jumper it from a breadboard.

It appears that avrdude does not invoke the auto-reset when using the stk500v1 protocol to the Uno R3 or Mega2560 R3.  It does if you use the "arduino" protocol.  So the reset capacitor really doesn't do anything in this case, except for going into Serial Monitor.

« Last Edit: June 17, 2013, 09:41:11 pm by hiduino » Logged

Pages: 1 ... 9 10 [11] 12 13 14   Go Up
Jump to: