Arduino Uno R3 as a true ISP programmer for any AVR

simplex:
Likely I will have to insert an "Wait 30 sec" instruction in the beginning of "Blink a led" program to have enough time to start Serial Monitor before the first "Led on" text is sent and before I open MISO as TX.

Nope. TinyISP has a command to hold the target in reset until the Monitor is started.

simplex:
As a question, if pin n of AVR 1 is connected to pin m of AVR 2 and both controllers transmit on pin n and m, respectively (this is and accidental collision of signals), can I damage the AVRs or no?

Yes. That can damage both processors. A 220 ohm (or higher) resistor in series solves the problem.

Most of the time, while trying to use avrdude with TinyISP loaded in Arduino Uno R3, I get the error: "avrdude: ser_open(): can't open device "\.\COM3": Access is denied."
I tried to reset Arduino Uno R3 but with no positive results. The error does nor disappear till I reload TinyISP. After that, I can use avrdude to load programs in the target Atmega328p but only a few times till the error appear again.
I also get errors like this with ArduinoISP but they disappear after resenting Arduino Uno R3.

c:\>avrdude -P COM3 -b 19200 -c avrisp -p m328p -v -u -n

avrdude: Version 5.10, compiled on Jun  4 2012 at 14:16:26
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "C:\Program Files\Atmel\AVR Tools\AVR Toolchain\bin\avrdude.conf"

         Using Port                    : COM3
         Using Programmer              : avrisp
         Overriding Baud Rate          : 19200
avrdude: ser_open(): can't open device "\\.\COM3": Access is denied.

Software Serial (UART) works with pin 18 (MISO) of target Atmega328p configured as TX
No more wiring changes, between programming and debugging with TinyISP, are needed

This is the test Bascom "Blink a led" program I used:

'Blink a LED

$regfile = "m328pdef.dat"
$crystal = 16000000
$baud = 9600

Waitms 30000

Config Portd = Output

Dim I As Integer

'Open a TRANSMIT channel for output

Open "comb.4:9600,8,n,1" For Output As #1

Print #1 , "Serial output on"

Do
 For I = 1 To 10
  Portd = 255
  Waitms 1000
  Print #1 , "Led on"
  Portd = 0
  Waitms 1000
  If I = 10 Then Goto Endprog
 Next I

Loop

Endprog:

Print #1 , "Serial output off"
Close #1

End

This is what I got in Serial Monitor Window of Arduino 1.0.1:

--- Monitor starting ---
Serial output on
Led on
Led on
Led on
Led on
Led on
Led on
Led on
Led on
Led on
Led on
Serial output off

--- Monitor stopped ---

So the output is in concordance with what I should get in the Serial Monitor.

However, there are two small problems:

1 ) The "Blink a led" program starts immediately after being loaded by TinyISP in the target Atmega328p. Without the instruction "Waitms 30000" (wait 30 seconds) I miss all the messages outputted before I start Serial Monitor with "!".

2 ) I would like TinyISP to be able also to transmit messages (commands given by my) from Serial Monitor to target Atmega328p, not just relay text from target Atmega328p to the Serial Monitor.
I would like TinyISP to understand not just a software serial TX run on target Atmega328p MISO (pin 18) but also a software serial RX on MOSI (pin 17), or on a different, already connected, SPI pin.
I guess that adding an RX facility beside already existent TX is not a difficult task for the one who wrote TinyISP.

simplex:
"avrdude: ser_open(): can't open device "\.\COM3": Access is denied."

An application on your computer is probing serial ports. The usual culprit is PDA / mobile phone synchronizer.

simplex:
1 ) The "Blink a led" program starts immediately after being loaded by TinyISP in the target Atmega328p. Without the instruction "Waitms 30000" (wait 30 seconds) I miss all the messages outputted before I start Serial Monitor with "!".

2 ) I would like TinyISP to be able also to transmit messages (commands given by my) from Serial Monitor to target Atmega328p, not just relay text from target Atmega328p to the Serial Monitor.
I would like TinyISP to understand not just a software serial TX run on target Atmega328p MISO (pin 18) but also a software serial RX on MOSI (pin 17), or on a different, already connected, SPI pin.
I guess that adding an RX facility beside already existent TX is not a difficult task for the one who wrote TinyISP.

Line #52:

[quote author=Coding Badly link=topic=125248.msg961884#msg961884 date=1350582326]

simplex:
"avrdude: ser_open(): can't open device "\.\COM3": Access is denied."

An application on your computer is probing serial ports. The usual culprit is PDA / mobile phone synchronizer.[/quote]

It appears that the parasitic application that disturbs avrdude is Arduino 1.0.1 Serial Monitor itself.

If Serial Monitor runs, avrdude displays "avrdude: ser_open(): can't open device "\.\COM3": Access is denied." while trying to upload a program with TinyISP in my target Atmega328p. If I close the Serial Monitor Window, avrdude no longer outputs "can't open device" error and I can upload the hex code to the target Atmega328p. If I start Serial Monitor (without issuing any command like "!", "@", etc.) again avrdude is unable to program the target AVR controller.
So, I do not have to program the target Atmega328p while Serial Monitor runs in parallel with avrdude, on my PC.

[quote author=Coding Badly]
Wiring the Serial Relay...
• Digital pin 12 on the Uno is receive. Connect transmit from the target to pin 12 on the Uno. This pin is also used when programming the target (MISO).
• Digital pin 14 (A0) on the Uno is transmit. It can be left unconnected or it can be connected to receive on the target.[/quote]
Source: SoftwareSerial with ATTiny84 using ATtiny library - #28 by Coding_Badly - Microcontrollers - Arduino Forum

This is line #52 of TinyISP / TinyISP_RelaySoftSerial.h

52: static SerialRelay RelaySerial( 12, 14 );

You suggest that I should change 14 with 11, like this: "static SerialRelay RelaySerial( 12, 11 );" ?
I found Arduino Uno pin mapping here: http://arduino.cc/en/Hacking/PinMapping168
Of course, in my "Blink a led" program I will have to implement a software Serial RX, TX being already functional.

This is all I have to change?

I made the change "static SerialRelay RelaySerial( 12, 14 );" -> "static SerialRelay RelaySerial( 12, 11 );"

TinyISP works now as a full TX, RX relay between my target Atmega328p and Serial Monitor Window. No supplemental connections are needed any more. Programming and debugging is done on the same (SPI) wires.

This is the test code:

'Test Bascom code that transform target Atmega328p in a character
'receiver/transmitter

'Any character sent from Arduino 1.0.1 Serial Monitor comes
'back and is displayed by the same Monitor.
'Arduino Uno R3 board, running TinyISP programmer/debugger, works as a relay
'between target Atmega328p (the controller that runs this Bascom code) and
'Serial Monitor Window on the PC.
'Target Atmega328p Port B, Pin 4 (MISO) works as software TX while
'Port B, Pin 3 (MOSI) is software RX
'By using software TX, RX, the same wiring configuration (SPI) used for
'programming target Atmega328p is also utilized for debugging and/or
'bidirectional data comunication between the PC and target Atmega328p.

$regfile = "m328pdef.dat"
$crystal = 16000000
$baud = 9600

Dim B As Byte
Waitms 100

'Open a TRANSMIT channel for output

Open "comb.4:9600,8,n,1" For Output As #1
Print #1 , "serial output"

'Now open a RECEIVE channel for input

Open "comb.3:9600,8,n,1" For Input As #2

'Since there is no relation between the input and output pin
'there is NO ECHO while keys are typed

Print #1 , "Press any alpha numerical key"

'With INKEY() we can check if there is data available
'To use it with the software UART you must provide the channel

Do

   'Store in byte

   B = Inkey(#2)

   'When the value > 0 we got something

   If B > 0 Then
      Print #1 , Chr(b)                                     'Print the character
   End If

Loop

Close #2                                                    'Close the channels
Close #1

End

And this is the output I get in the Serial Monitor when I send characters f g h to the target Atmega328p.

--- Monitor starting ---
f
g
h

--- Monitor stopped ---

It looks like Arduino Uno R3 can be used as a true programmer/debugger now!

Um. A serial connection does not make a "true debugger."

westfw:
Um. A serial connection does not make a "true debugger."

It does make a "better than nothing debugger." :smiley:

Hi 8)

Can I use Arduino as AVR Programmer :grin: Like USBASP or STK200/300 or ST500 or ... Just for Programm my AVR chip?! ::slight_smile:

Only want to Upload a HEX file to AVR chips NOT Bootloader!!! :sleeping:

Is possible? :grin: