Forum Index > Projects > LED Pegboard and Matrix Projects
 Can't upload file to Peggy (atmega328)
 |  Printable Version
By: Anonymous: Raul Diaz Poblete () on Monday, May 25 2009 @ 02:48 PM PDT (Read 4793 times)  
Anonymous: Raul Diaz Poblete

Hi all!

I'm ussing a Peggy 2.1 with an ATmega328p with bootloader on Windows XP.

I've upload some Arduino sketches from Peggy library for Arduino using USB-TTL wire and it works well. But I was wondering I need to press reset button after click upload in Arduino IDE. I suposse an ATmega328 doesn't need a reset. Am I wrong?

Anyway, the problem appear when I try to upload the c code from great Jay's project about communicate Peggy and Arduino using TWI protocol (http://planetclegg.com/projects/Twi2Peggy.html).

First I couldn't compile the code for an ATmega328 model: If I only change the MCU configuration to MCU=atmega328p I get an error about PBn and PCn variables were undeclared.

In this post (http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1237133962/4#4) I get the solution: to change PBn for PINBn and PCn for PINCn. Then code is compiled without errors!

So now the last step has gone! Uploading!
I'm using WinAVR 20090313 and avrdude 5.6 . I try with an USBTinyISP programer and this avrdude configuration in makefile:

PHP Formatted Code
AVRDUDE_PROGRAMMERID=usbtiny
AVRDUDE_PORT= usb



But that's what I get:

avrdude: error: usbtiny_transmit: usb_control_msg: sending control message failed, win error: One of the devices linked to the systems i not working.


I try with an USB-TTL wire and this configuration:

PHP Formatted Code
AVRDUDE_PROGRAMMERID=avrisp
AVRDUDE_PORT=com1
AVRDUDE_EXTRA = -b19200 -F



and nothing happens! Command line looks waiting for nothing.

If I press the reset buttom of Peggy I get this error:

PHP Formatted Code
avrdude: stk500_getsync(): not in sync: resp=0x00



and command line is waiting again. If a press reset again I get:

PHP Formatted Code
avrdude: stk500_disable(): protocol error, expecte=0x14, resp=0x00
and the get avrdude done. nake: ** [writeflash] Error 1



If I try sdk500 instead avrisp in makefile configuration:

PHP Formatted Code
AVRDUDE_PROGRAMMERID=sdk500



I obtain the same behaviour.


So now I get stuck on this step.
I've seen on this forum that some other people had problems uploading with ATmega328.
But I have no problem uploading from Arduino IDE! Only with avrdude and Jay's code!
I would like to know about some experiences using the code of Jay's project with an ATmega328.

Anyway any advice or suggestion would be apreciated.

Sorry for the long post and thanks in advance!





       
   
By: Windell (offline) on Monday, May 25 2009 @ 03:29 PM PDT  
Windell

Okay, you've got a number of separate issues, and it does not make anything easier that you're trying to solve them all at once.


But I was wondering I need to press reset button after click upload in Arduino IDE. I suposse an ATmega328 doesn't need a reset. Am I wrong?

Both the '168 and '328 need to be reset for programming, however the Peggy uses an "auto-reset" circuit that allows the USB-TTL cable to do this for you. Normally, you should not need to press the reset button by hand.


First I couldn't compile the code for an ATmega328 model: If I only change the MCU configuration to MCU=atmega328p I get an error about PBn and PCn variables were undeclared.

In this post (http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1237133962/4#4) I get the solution: to change PBn for PINBn and PCn for PINCn. Then code is compiled without errors!

Yes, that technically works, but it's an incredibly bad idea. That forum post is dangerous.

"PB6" is shorthand in the code-- defined for the '168 but not the '328-- that is meant to represent pin 6 of PORTB -- in other words, output pin 6 of port B. There's also a shorthand PINB6 that represents input from pin 6 of port B. It's *very sloppy shorthand,* because "PB6" alone doesn't clearly specify output or input by its name alone. This was changed (for the better) in the '328 io definition file (iom328p.h), so that the shorthand names are now PORTB6 (for output) and PINB6 (for input) are now available. When you change the name from PB6 to PINB6, what you are *really* doing is writing down in the code "Use input, not output." This is a bad, bad idea from the standpoint of future changes to that code-- it will make it non-understandable.

(Under the hood, PB6, PINB6, PORTB6 are *all* are translated into the number '6'. So, by pure coincidence, your code will actually work the same if you do make this change, but it's just a bad, bad, bad idea anyway.)

Now go back, start over with the code, and search replace every instance of "PB6" with "PORTB6" -- or better yet, by the simple number '6', and so forth. Then it won't be horribly wrong everywhere. Smile

Now on the programming, stick with the USBtiny (or pick ONE interface-- if you try three interfaces at once you'll never get anywhere on any of them). Make sure that the cable is plugged in with the correct orientation, that the Peggy power is on (and working), that the USBtiny 5V power jumper is off. Then unplug the USB cable from your computer and plug it back in and try again.



Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/

Forum Evil Scientist
Evil Scientist

Status: offline

Registered: 06/15/06
Posts: 1932
Sunnyvale, CA

Profile Email Website  
   
By: Peter_er (offline) on Wednesday, June 22 2011 @ 09:30 AM PDT  
Peter_er

And it will work for Vista, no? What changes should be done?


Forum Apprentice
Apprentice

Status: offline

Registered: 06/22/11
Posts: 2

Profile Email    
   
By: Windell (offline) on Wednesday, June 22 2011 @ 09:42 AM PDT  
Windell

Vista is supported, just fine.


Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/

Forum Evil Scientist
Evil Scientist

Status: offline

Registered: 06/15/06
Posts: 1932
Sunnyvale, CA

Profile Email Website  
   



 All times are PDT. The time is now 02:56 PM.
Normal Topic Normal Topic
Locked Topic Locked Topic
Sticky Topic Sticky Topic
New Post New Post
Sticky Topic W/ New Post Sticky Topic W/ New Post
Locked Topic W/ New Post Locked Topic W/ New Post
View Anonymous Posts 
Able to Post 
Filtered HTML Allowed 
Censored Content 

Evil Mad Scientist Forum Archives — Read only!

Please visit our new forums for new discussions.


DIY Hardware for Electronic Art


The Original Egg-Bot Kit


Octolively
Interactive LED kits


Meggy Jr RGB
LED matrix game
development kit.


Business-card sized
AVR target boards


Peggy 2
LED Pegboard kits

My Account






Lost your password?