📣📪 🚚 Adafruit will not be shipping USPS orders Monday October 14, 2019 🗓. Expedited USPS orders placed after 11am ET 🕚 Friday October 11 will go out Tuesday October 15 📣📪🚚
0

Newbie help needed...
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Newbie help needed...

by Watson on Sun Sep 28, 2008 3:12 pm

I'm trying to run a Attiny2313 with this test program:

#include <avr/io.h> // this contains all the IO port definitions

int main(void) {

DDRB = 0xFF; // set all 8 pins on port B to outputs

PORTB = 0xFF; // set all the pins on port B high (turn on those LEDs)

while (1); // basically halt, do nothing forever
}

I get an Ok message from avrdude (like this http://www.ladyada.net/images/avrtutori ... exprog.jpg) when burning the chip with this program's HEX, but the chip refuses to work! I connected some LEDs to PORTB same way MINIPOV3 does (http://www.ladyada.net/images/minipov3/minipov3schem.png) and there is no LED activity... help :(
Watson
 
Posts: 20
Joined: Sun Sep 21, 2008 2:54 pm

by mtbf0 on Sun Sep 28, 2008 3:28 pm

in the absence of the actual output from avrdude and a picture of the circuit i'd guess led polarity.
"i want to lead a dissipate existence, play scratchy records and enjoy my decline" - iggy pop, i need more
User avatar
mtbf0
 
Posts: 1645
Joined: Sat Nov 10, 2007 12:59 am
Location: oakland ca

by oPossum on Sun Sep 28, 2008 3:40 pm

Make sure the AVR's configuration fuses are set correctly.
oPossum
 
Posts: 636
Joined: Fri Oct 26, 2007 12:42 am
Location: Michigan, USA

by Watson on Sun Sep 28, 2008 3:59 pm

mtbf0,

the output is almost exactly like this one http://www.ladyada.net/images/avrtutori ... exprog.jpg except that i'm burning all_leds.hex and not test_leds.hex. The LED's polarity have been triple checked.


oPossum,

I read about fuses here http://www.ladyada.net/learn/avr/fuses.html but I thought that AVRDUDE would take care of them itself. How do I burn them onto the chip?
Last edited by Watson on Sun Sep 28, 2008 4:10 pm, edited 1 time in total.
Watson
 
Posts: 20
Joined: Sun Sep 21, 2008 2:54 pm

by Watson on Sun Sep 28, 2008 4:02 pm

Oh - I read again about programming here http://www.ladyada.net/learn/avr/avrdude.html and it says "...or hfuse, lfuse or efuse for the chip configuration fuses, but we aren't going to mess with those" - I guess this scared me a little :) i'll experiment with this.... (the -U option)
Watson
 
Posts: 20
Joined: Sun Sep 21, 2008 2:54 pm

by Watson on Sun Sep 28, 2008 4:15 pm

Bummer, the fuse calculator suggested here http://www.ladyada.net/learn/avr/fuses.html - which is http://sourceforge.net/projects/palmavr/ - is for Palm OS...
Watson
 
Posts: 20
Joined: Sun Sep 21, 2008 2:54 pm

by Watson on Sun Sep 28, 2008 4:42 pm

Ok, using this one http://www.vonnieda.org/AVRFuses/ (there are Mac & Windows versions)

What are the values of the fuses to be used with lets say - MiniPOV3? Or, where can I find them? I mean, the schematics and the firmware are provided, what about the fuses? where should a newbie look? AND, reading about fuses in the tutorial (http://www.ladyada.net/learn/avr/fuses.html), I don't find any "critical" looking fuse to be set... the default values looks ok to me.. :roll:

Anyway, I've used these:
- Preserve EEPROM
- SPI enabled
- BOD = 4.3V
- Int. RC Osc. 8MHz, 14 CK + 65 ms

Burning the fuses was a success but still no signs of life from the chip...
Watson
 
Posts: 20
Joined: Sun Sep 21, 2008 2:54 pm

by macegr on Sun Sep 28, 2008 5:57 pm

Are you sure your LED resistor values are correct? 47 ohms, not 47 kohms or something?
macegr
 
Posts: 292
Joined: Fri Apr 04, 2008 4:46 pm

by mtbf0 on Sun Sep 28, 2008 6:55 pm

dumped the fuses on my brain machine.

Code: Select all | TOGGLE FULL SIZE

/home/user> avrdude -c dasa -p t2313 -P /dev/ttyUSB0 -v

avrdude: Version 5.5, compiled on Feb  9 2008 at 04:38:00
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/

         System wide configuration file is "/usr/local/etc/avrdude.conf"
         User configuration file is "/home/user/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port            : /dev/ttyUSB0
         Using Programmer      : dasa
         AVR Part              : ATtiny2313
         Chip Erase delay      : 9000 us
         PAGEL                 : PD4
         BS2                   : PD6
         RESET disposition     : possible i/o
         RETRY pulse           : SCK
         serial program mode   : yes
         parallel program mode : yes
         Timeout               : 200
         StabDelay             : 100
         CmdexeDelay           : 25
         SyncLoops             : 32
         ByteDelay             : 0
         PollIndex             : 3
         PollValue             : 0x53
         Memory Detail         :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65     6     4    0 no        128    4      0  4000  4500 0xff 0xff
           flash         65     6    32    0 yes      2048   32     64  4500  4500 0xff 0xff
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00
           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           calibration    0     0     0    0 no          2    0      0     0     0 0x00 0x00

         Programmer Type : SERBB
         Description     : serial port banging, reset=rts sck=dtr mosi=txd miso=cts

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.31s

avrdude: Device signature = 0x1e910a
avrdude: safemode: lfuse reads as E4
avrdude: safemode: hfuse reads as DF
avrdude: safemode: efuse reads as FF

avrdude: safemode: lfuse reads as E4
avrdude: safemode: hfuse reads as DF
avrdude: safemode: efuse reads as FF
avrdude: safemode: Fuses OK

avrdude done.  Thank you.

/home/user>


to burn these settings run this command

Code: Select all | TOGGLE FULL SIZE
avrdude -c dasa -p t2313 -P /dev/ttyUSB0 -U lfuse:w:0xE4:m -U hfuse:w:0xDF:m


of course, you'll have to supply a port name in place of "/dev/ttyUSB0" that is appropriate for your os.
Last edited by mtbf0 on Sun Sep 28, 2008 8:30 pm, edited 1 time in total.
"i want to lead a dissipate existence, play scratchy records and enjoy my decline" - iggy pop, i need more
User avatar
mtbf0
 
Posts: 1645
Joined: Sat Nov 10, 2007 12:59 am
Location: oakland ca

by magician13134 on Sun Sep 28, 2008 7:11 pm

Ummm, this may be stupid, but can you say this:
Code: Select all | TOGGLE FULL SIZE
while (1);
?
Doesn't it need to be
Code: Select all | TOGGLE FULL SIZE
while (1){}
?
magician13134
 
Posts: 1119
Joined: Wed Jun 13, 2007 9:17 am
Location: Ann Arbor

by mtbf0 on Sun Sep 28, 2008 7:18 pm

magician13134 wrote:Ummm, this may be stupid, but can you say this:
Code: Select all | TOGGLE FULL SIZE
while (1);
?
yes.
magician13134 wrote:Doesn't it need to be
Code: Select all | TOGGLE FULL SIZE
while (1){}
?
not necessarily.
"i want to lead a dissipate existence, play scratchy records and enjoy my decline" - iggy pop, i need more
User avatar
mtbf0
 
Posts: 1645
Joined: Sat Nov 10, 2007 12:59 am
Location: oakland ca

by The_Don125 on Sun Sep 28, 2008 7:37 pm

Is it possible the compiler is noticing nothing in the while loop, and simply removing it? Maybe try:
Code: Select all | TOGGLE FULL SIZE
#include <avr/io.h> // this contains all the IO port definitions

int main(void)
{
     DDRB = 0xFF; // set all 8 pins on port B to outputs
     while (1) // loop forever
     {
          PORTB = 0xF0; // set half the pins on port B high, and the other half low
     }
}

The_Don125
 
Posts: 373
Joined: Tue Mar 06, 2007 11:51 pm
Location: Illinois

by oPossum on Sun Sep 28, 2008 9:01 pm

Code: Select all | TOGGLE FULL SIZE
// Tell the compiler that 'a' can be changed by something outside
// the loop so it will not optimize away any loop that tests 'a'
volatile int a=1;
while(a);
oPossum
 
Posts: 636
Joined: Fri Oct 26, 2007 12:42 am
Location: Michigan, USA

by Watson on Mon Sep 29, 2008 4:31 am

I assume that Ladyada's test_leds program has been used before "as is"... :)

Anyway, I also used this code (from alt_leds.c):

Code: Select all | TOGGLE FULL SIZE
#include <avr/io.h>      // this contains all the IO port definitions
#include <util/delay.h>

// This function basically wastes time
void delay_ms( uint16_t milliseconds)
{
   for( ; milliseconds > 0; milliseconds--)
   {
      _delay_ms( 1);
   }
}


int main(void) {

  DDRB = 0xFF;       // set all 8 pins on port B to outputs
 
  PORTB = 0x0;       // set all pins on port B low (turn off LEDs)

  while (1) {
    PORTB = 0xAA;      // turn on LEDs #2,4,6,8

    delay_ms(500);    // delay half a second

    PORTB = 0x55;      // turn on LEDs #1,3,5,7

    delay_ms(500);    // delay half a second
  }
}


No visible chip activity.


Mtbf0, I tried using that fuse values you supplied (mine were: LOW=0xe4, HIGH=0xd9, EXTENDED=0xff). Still nothing.
Watson
 
Posts: 20
Joined: Sun Sep 21, 2008 2:54 pm

by Watson on Mon Sep 29, 2008 4:43 am

ISSUE RESOLVED GA~!@#IT!

(almost:)

The moment I unplugged the serial cable it started working. Why is that, electronically?

--

Checking, I see the serial cable's pin7 takes the AVR's pin 1 (^reset) low...

BTW: Is there a way to enable the circuit AND having it connected to the serial? This way I could make use it to control stuff by computer via serial AND update it's firmware in a "press of a button"! :twisted:
Last edited by Watson on Mon Sep 29, 2008 8:52 am, edited 1 time in total.
Watson
 
Posts: 20
Joined: Sun Sep 21, 2008 2:54 pm

Please be positive and constructive with your questions and comments.