Need a nudge in the right direction

For Adafruit customers who seek help with microcontrollers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
shobley
 
Posts: 184
Joined: Fri Sep 07, 2007 5:16 pm

Need a nudge in the right direction

Post by shobley »

So.....

1. Built USBTinyISP ... check
2. Wrestled with driver signing in Win 7 ... check
3. Downloaded and flashed 328P with the test hex file ... check
4. Flash verification complete ... check

Now, what should happen next?

I have the "Evil Mad Scientist" board hooked up to the USBTinyISP - and I have that wired up just like in the pictures. The red LED on the programmer flashes, and so does the larger LED on the EMS board during the avrdude process.

I guess now I need to set the fuses, or something... :?

- would someone care to help me over the finish line...?

Thanks,
Steve

uhe
 
Posts: 178
Joined: Mon Sep 03, 2007 4:50 pm

Re: Need a nudge in the right direction

Post by uhe »

Hi

which EMS board are you talking about? Peggy2?
What do expect that should happen next? Should this test hex file do/display sth.?

The fuses are usually set at the end of flashing the new firmware/hex-file. There might be a line in your Makefile like:

Code: Select all

#AVRDUDE_FLAGS += -U lfuse:w:0x62:m -U hfuse:w:0xdf:m -U efuse:w:0xf9:m 
If you uncomment this the avrdude should set the lfuse, hfuse and efuse to these values.
Make shure that you write the right values, this can render your microcontroller unusable!

shobley
 
Posts: 184
Joined: Fri Sep 07, 2007 5:16 pm

Re: Need a nudge in the right direction

Post by shobley »

Board : http://www.adafruit.com/index.php?main_ ... 243b1c6bd8

Yeah I guessed that was the next step.

I've been following the tutorial here:

http://www.ladyada.net/learn/avr/avrdude.html

But it kind of skips out at the end - it says I need to set the fuses, but I'm not sure what values I should set them to - 328P chip.
I'm also not really sure what the test_leds.hex actually does.

I'm assuming that I need to write some C code, and then GCC it into a hex file - but not really sure what libraries to include etc... are there any tutorials on that?

(I've been a pure Arduino guy for too long, I thought it time I tried all this stuff for real.)

uhe
 
Posts: 178
Joined: Mon Sep 03, 2007 4:50 pm

Re: Need a nudge in the right direction

Post by uhe »

shobley wrote:But it kind of skips out at the end - it says I need to set the fuses, but I'm not sure what values I should set them to - 328P chip.
I'd say if it works leave them as they are. You can also use AVRdude to read the fuses somehow (I don't know which options to apply, just google for read avr fuses). Then you can enter the values into the fuse calculator mentioned in the tutorial and see whats up.
shobley wrote:I'm also not really sure what the test_leds.hex actually does.
Look at the blink.c and the Makefile in the hello world zip.
shobley wrote:I'm assuming that I need to write some C code, and then GCC it into a hex file - but not really sure what libraries to include etc... are there any tutorials on that?
There are good tutorials but I don't know any to point at :(
But there is sourcecode that you could read, UTSL ;)
shobley wrote:(I've been a pure Arduino guy for too long, I thought it time I tried all this stuff for real.)
In C one could say: everything starts with main(). From the hello world code:

Code: Select all

int main(void) {
  DDRB = (1 << 5);  // set PORTB5 to an output

  while(1) {
    PORTB |= 1 << 5;  // turn LED on
    _delay_ms(100);
    PORTB &= ~(1 << 5);  // turn LED off
    _delay_ms(100);
  }
}
In arduino land I think the example would look like this:

Code: Select all

void setup(void) {
  // set PORTB5 to an output
}

void loop(void) {
  // turn LED on
  _delay_ms(100);
  // turn LED off
  _delay_ms(100);
} 

int main(void) {
  setup();
  while(1) { 
    loop();
  }
}

It's not that different!

User avatar
opossum
 
Posts: 636
Joined: Fri Oct 26, 2007 12:42 am

Re: Need a nudge in the right direction

Post by opossum »

You can use an AVR Fuse Caculator to determine the hex values for the fuses.

Make sure you do not turn on Debug Wire or turn on Reset Disabled (leave both unchecked). Turning either of those on will prevent programming by a low voltage programmer like the USBTinyISP.

User avatar
opossum
 
Posts: 636
Joined: Fri Oct 26, 2007 12:42 am

Re: Need a nudge in the right direction

Post by opossum »

shobley wrote: I'm also not really sure what the test_leds.hex actually does.
It is for the MiniPOV3. Source Code

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: Need a nudge in the right direction

Post by adafruit »

Please dont start messing with fuses, its not necessary and may brick your chip if you're not sure of what you're doing

go here
http://www.adafruit.com/index.php?main_ ... cts_id=174
Download the (updated) atmega328 blink zip and follow the directions
"To get you started, here is a 'hello world' zip file. It contains a C program, compiled .hex file and Makefile for a blinking LED connected to pin PB5. Wire up the board as shown here (don't forget the 3 jumper wires up top, they are essential!) Then install WinAVR or equivalent and run make program in the uncompressed folder to compile and burn the example. "

shobley
 
Posts: 184
Joined: Fri Sep 07, 2007 5:16 pm

Re: Need a nudge in the right direction

Post by shobley »

Perfect! That's what I was looking for...

Locked
Please be positive and constructive with your questions and comments.

Return to “Microcontrollers”