Go Down

Topic: Help! (Read 6342 times) previous topic - next topic

clivemist

Hi.

I am using a diy 328p-au with a 16mhz crystal, and an 8u2 (ala Arduino R2).

I have managed to bootload, and upload a sketch to check the serial connection.
I have tried changing fuses, .hex, boards.txt, a fresh version of the IDE.


I have uploaded the following using an arduino R3:


"void setup()                   
{
  Serial.begin(14400);           
}

void loop()                     
{
  Serial.println("Hello world!"); 
  delay(1000);
}



On the serial connection I dont get a read out unless I multiply the baud by 8.
(eg 14400 = 115200).


Obviously this means I can not upload any sketches direct.

Sort of at a loose end, and after 2 weeks of trying various things I am getting increasingly confussed and frustrated.

Could this be a fuse issue, an 8u2 issue, or something else that I've missed?



Any help would be appreciated before I loose my mind!


Thanks in advance.

Nikarus

These are both simply chips on breadboards your tryign to get talking right now, or is 1 of them actually an arduino R2?

clivemist

Thanks for the reply Nikarus.

I have an 8u2 and 328p-au soldered to a PCB.

I used an Arduino R3 to burn the bootloader.

clivemist

Using the fuse calc at http://www.engbedded.com/fusecalc I am setting up with the following settings, and then changing in the board.txt:

Ext. Full swing. 16k CK/14CK+65ms [CKSEL=0111 SUT=11]
Enable SPI.

This gives me back:

-U lfuse:w:0xf7:m -U hfuse:w:0xd9:m -U efuse:w:0xff:m

I've also tried:

-U lfuse:w:0xe0:m -U hfuse:w:0xd9:m -U efuse:w:0xff:m

Aswell as checking and unchecking the [CKDIV8=0] selection.


I've read that the 328p and 328p-au are different.

Where am I going wrong?
Any help would be much appreciated!

floresta

Quote
On the serial connection I dont get a read out unless I multiply the baud by 8.

This implies that the clock frequency is being divided by 8 which is the default condition.  So yes, this could be a fuse issue (see below).

Quote
I've read that the 328p and 328p-au are different.

They have a different number of pins, 32 vs 28 and the extra four pins are not just tacked on at the end.  In other words the functions of each of the pins 1-28 on the 32 pin chip do not match the functions of the corresponding pins on the 28 pin chip.  For example, the crystal goes to pins 9 and 10 on the 328p and to pins 7 and 8 on the 328p-au.

Quote
Using the fuse calc at http://www.engbedded.com/fusecalc I am setting up with the following settings, ...

Have you looked at the default settings here: --> http://www.codingwithcody.com/2011/04/arduino-default-fuse-settings/ ?

Don

clivemist

Hi Don.

Just checked out the link, so thanks for that!

Yes, they seem to match up..


##############################################################

uno.name=Arduino Uno
uno.upload.protocol=arduino
uno.upload.maximum_size=32256
uno.upload.speed=115200
uno.bootloader.low_fuses=0xff
uno.bootloader.high_fuses=0xde
uno.bootloader.extended_fuses=0x05
uno.bootloader.path=optiboot
uno.bootloader.file=optiboot_atmega328.hex
uno.bootloader.unlock_bits=0x3F
uno.bootloader.lock_bits=0x0F
uno.build.mcu=atmega328p
uno.build.f_cpu=16000000L
uno.build.core=arduino
uno.build.variant=standard


Part of the reason I chose the SMD version is because of the extra capability of the IC, and that it comes in as a TQFP.

This is the second time this has happened on two sepperate boards, although I am yet to get one to fire up and upload a sketch.

I've tried to get my head around AVR Dude, but finding it quite difficult using the Arduino R3 as a programmer.

What I have noticed is that when I change the boards.txt it doesn't appear in my IDE (only just noticed) so would imagine that changing the fuses here has had no effect..

clivemist

Using this sketch (thanks goes out to nOOb for this http://www.n00bsys0p.co.uk/blog/2012/07/09/reading-hfuse-lfuse-and-efuse-arduno-ide:):


#include <avr/boot.h>

void setup() {
  Serial.begin(14400);
  int lf = boot_lock_fuse_bits_get(GET_LOW_FUSE_BITS);
  int hf = boot_lock_fuse_bits_get(GET_HIGH_FUSE_BITS);
  int ef = boot_lock_fuse_bits_get(GET_EXTENDED_FUSE_BITS);

  Serial.println("Low Fuse Bits: ");
  Serial.println(lf);
  Serial.println("High Fuse Bits: ");
  Serial.println(hf);
  Serial.println("Extended Fuse Bits: ");
  Serial.println(ef);
}

void loop() {
  // Do nothing
}



I got this result back:

Low Fuse Bits:
255
High Fuse Bits:
222
Extended Fuse Bits:
253


Which is equal to:

Low Fuse Bits:
FF
High Fuse Bits:
DE
Extended Fuse Bits:
FD


Not quite sure why this is, and changing the board.txt seems to have no effect..

clivemist

#7
Oct 30, 2012, 01:56 am Last Edit: Oct 30, 2012, 01:59 am by clivemist Reason: 1
Ok.. I had a play with AVRDude. I kind of get it now!

I managed to get this running with the R3 as an ISP using:

"avrdude -c arduino -P com3 -p m328p -b 19200 -U lfuse:w:0xFF:m"
"avrdude -c arduino -P com3 -p m328p -b 19200 -U hfuse:w:0xDE:m"
"avrdude -c arduino -P com3 -p m328p -b 19200 -U efuse:w:0x05:m"

This confirms when I verify:

"avrdude -c arduino -P com3 -p m328p -b 19200 -U lfuse:v:0xFF:m"
"avrdude -c arduino -P com3 -p m328p -b 19200 -U hfuse:v:0xDE:m"
"avrdude -c arduino -P com3 -p m328p -b 19200 -U efuse:v:0x05:m"

I get back all confirmed as correct.


I used this sketch again:

"#include <avr/boot.h>

void setup() {
 Serial.begin(300);
 int lf = boot_lock_fuse_bits_get(GET_LOW_FUSE_BITS);
 int hf = boot_lock_fuse_bits_get(GET_HIGH_FUSE_BITS);
 int ef = boot_lock_fuse_bits_get(GET_EXTENDED_FUSE_BITS);

 Serial.println("Low Fuse Bits: ");
 Serial.println(lf, HEX);
 Serial.println("High Fuse Bits: ");
 Serial.println(hf, HEX);
 Serial.println("Extended Fuse Bits: ");
 Serial.println(ef, HEX);
}

void loop() {
 }"


Which only works at baud 2400 (again 8x what its meant to be!) and returns:

"Low Fuse Bits:
FF
High Fuse Bits:
DE
Extended Fuse Bits:
FD"


I am also getting back a device signature of "0x1e950f" which is (apparently) correct.

Yet still no go on the being able to upload, even though I have a form of TX/RX sending back through the 8u2 I'm trying to link up with.. (Due to the CKDIV8 not working, or something to do with the 8u2).


Why AVRDude see's the fuses as being set correctly and the Arduino IDE can not, I am at a complete loss.


In the meantime I am going to knock up another couple of boards and see if I get the same response..

If anyone has any other info on this please let me know!
Thanks in advance.

clivemist

Solved the baud rate issue..

Now the serial posts back at the correct rate, but I need to apply the CKDIV8 option.

The line:

"avrdude -c arduino -P com3 -p m328p -b 19200 -U lfuse:w:0xFF:m"

Was fixed by:

"avrdude -c arduino -P com3 -p m328p -b 19200 -U lfuse:w:0x77:m"

Yet still no upload?..

The search continues..

Go Up