Go Down

Topic: Digital Pin 6 pullup resistor? (Read 1 time) previous topic - next topic

paulb

#10
Jul 09, 2007, 12:49 pm Last Edit: Jul 09, 2007, 01:03 pm by paulb Reason: 1
This is from the 168 bootloader code:
http://svn.berlios.de/wsvn/arduino/trunk/bootloader168-diecimila/ATmegaBOOT_168.c?op=file&rev=0&sc=0


Here's the definition of PIND6 (digital pin  6) in the bootloader.


/* other ATmegas have only one UART, so only one pin is defined to enter bootloader */
#define BL_DDR  DDRD
#define BL_PORT PORTD
#define BL_PIN  PIND
#define BL      PIND6
#endif


According to the comment, this appears to be the smoking gun where the pin6 pullup gets set

/* set pin direction for bootloader pin and enable pullup */
   /* for ATmega128, two pins need to be initialized */
#ifdef __AVR_ATmega128__
   BL_DDR &= ~_BV(BL0);
   BL_DDR &= ~_BV(BL1);
   BL_PORT |= _BV(BL0);
   BL_PORT |= _BV(BL1);
#else

   BL_DDR &= ~_BV(BL);
   BL_PORT |= _BV(BL);
#endif


I'm guessing that pin 6 is being setup as some kind of switch for changing the bootloader's behavior?  
I can't seem to find anywhere where the pin is being checked though.

I was to going to try commenting out, compiling a new hex file and burning to a chip to test.
I think I need to do this with a gcc command from the terminal window for this.

Can someone please point me to the correct procedure for this?



admin

I think you spotted it

I forgot about this,


The original bootloader we used to make the arduino bootloader would start only if pin D6 was low... we removed that requirement
but not the initialisation code

get rid of that stuff


massimo


mellis

Thanks for spotting that Paul.  I'll be sure to correct it for the Diecimila.

BTW, that bootloader is intended for the Diecimila, which will have an automatic software reset and thus shorter timeouts.  If you want to test it, you should first change the MAX_TIME_COUNT to something like (F_CPU >> 1).  You could also change flash_led(1); to flash_led(3); if you want the LED to flash three times instead of one when the bootloader starts.  

To compile the bootloader, you can just run "make" - the makefile should do the right thing, assuming you have avr-gcc, etc. in your path.  To upload it with an AVRISPmkII you can run "make isp". For other programmers, you'll need to call avrdude manually or edit the makefile.

macmaniac

sorry this is a bit n00bish, but what do I remove from the bootloader? Is it this:
/* set pin direction for bootloader pin and enable pullup */
   /* for ATmega128, two pins need to be initialized */
#ifdef __AVR_ATmega128__
   BL_DDR &= ~_BV(BL0);
   BL_DDR &= ~_BV(BL1);
   BL_PORT |= _BV(BL0);
   BL_PORT |= _BV(BL1);
#else

   BL_DDR &= ~_BV(BL);
   BL_PORT |= _BV(BL);
#endif

Thanks,
               Macmaniac

paulb

Just comment these two lines, like so



#else

//   BL_DDR &= ~_BV(BL);
//   BL_PORT |= _BV(BL);
#endif  

Go Up