i have a uno r3 board with its chip and two Atmega328P on breadboard configured with a 16 MHz crystal as described on http://arduino.cc/en/Main/Standalone.
I burned bootloader using the Arduino board and ArduinoISP to one of the chip and upload blinker sketch and it works fine.
I use the same configuration to program the AVR chip directly and upload program using AVRDUDE. However, the program can not turn on LED on PB6 and PB7. I know it is not the code issue, because the same code can upload and work correctly with my other chip without the Arduino bootloader.
I erased the bootloader using the -e option with ARVDUDE, but the two pins are still not working. I know the bootloader is erased because i can not upload sketch with arduino IDE when i put the chip in the Arduino board.
I removed the 16 MHz crystal and the two capacitors and repeated step 2 above, but ARVDUDE failed to upload program to the chip.
do you any of you out there have this problem and know how to set the chip to its original state? your response is appreciated.
See here in the datasheet
28.2 Fuse Bits
The ATmega48A/PA/88A/PA/168A/PA/328/P has three Fuse bytes. Table 28-4 - Table 28-9 on page 288 describe briefly the functionality of all the fuses and how they are mapped into the Fuse bytes. Note that the fuses are read as logical zero, “0”, if they are programmed.
So you would need to change the fuses, and then "burn them in" (i.e. program them" using an AVR ISP or Programmer, which connects to the SCK-MISO-MOSI-Reset-Power-Gnd pins (the ICSP header usually) to access the fuses directly to program them.
You can find an online fuse calculator to help you determine the settings.
I do not know of a board type that uses PB6 & 7, so you need a new group of boards.txt entries, and a new pins_arduino.h to map the pins to software names (like D20, D21) so that code can access them. (or use direct port manipulation I guess).