Home · Register · Join Upload & Sell

Moderated by: Fred Miranda
Username  

  New fredmiranda.com Mobile Site
  New Feature: SMS Notification alert
  New Feature: Buy & Sell Watchlist
  

FM Forums | Lighting & Studio Techniques | Join Upload & Sell

  

Archive 2018 · ATMEGA328p LED is not blinking

  
 
Bresee
Offline

Upload & Sell: Off
p.1 #1 · p.1 #1 · ATMEGA328p LED is not blinking


I tried to build a test circuit based on the Book "AVR Programming". It is very simple and shown here:




The circuit itself is working and the upload of my code as well:

#include <avr/io.h>                        /* Defines pins, ports, etc */
#define F_CPU 1000000UL
#include <util/delay.h> /* Functions to waste time */


int main(void) {

DDRB |= 0b00000001;

while (1) {

PORTB = 0b00000001;
_delay_ms(1000);
PORTB = 0b00000000;
_delay_ms(1000);

}
return 0;
}


but the ATMEGA328p([url]http://www.kynix.com/Detail/551814/ATMEGA328P.html[/url]) LED is not blinking. The LED in the lower right is lighting up so the circuit seems fine. There are no error messages in ATMEL Studio and the circuit setup seems fine to me. The hex file flashes correctly onto the chip. I even changed the LED and the ATMEL chip to a new one and still the same result. I am running out of debugging ideas.



The fuse settings and avrdude output:

avrdude.exe: Version 6.3, compiled on Feb 17 2016 at 09:25:53
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

System wide configuration file is "C:WinAVR-20100110binavrdude.conf"

Using Port : usb
Using Programmer : usbtiny
avrdude.exe: usbdev_open(): Found USBtinyISP, bus:device: bus-0:\.libusb0-0001--0x1781-0x0c9f
AVR Part : ATmega328P
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PC2
RESET disposition : dedicated
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 20 4 0 no 1024 4 0 3600 3600 0xff 0xff
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00

Programmer Type : USBtiny
Description : USBtiny simple USB programmer, http://www.ladyada.net/make/usbtinyisp/
avrdude.exe: programmer operation not supported

avrdude.exe: Using SCK period of 10 usec
CMD: [ac 53 00 00] [ac 52 53 00]
avrdude.exe: AVR device initialized and ready to accept instructions

Reading | CMD: [30 00 00 00] [00 30 00 1e]
CMD: [30 00 01 00] [00 30 00 95]
################CMD: [30 00 02 00] [00 30 00 0f]
################################## | 100% 0.01s

avrdude.exe: Device signature = 0x1e950f (probably m328p)

avrdude.exe done. Thank you.


The AVRDUDE command line I am using:
avrdude -c usbtiny -p m328p -v -v -v -u flash:w:Test.hex:i



Jan 08, 2018 at 02:56 AM
Bresee
Offline

Upload & Sell: Off
p.1 #2 · p.1 #2 · ATMEGA328p LED is not blinking


The ATMEGA328p I used is this one:http://www.kynix.com/Detail/551814/ATMEGA328P.html


Jan 08, 2018 at 02:59 AM
Access
Offline
• • •
Upload & Sell: Off
p.1 #3 · p.1 #3 · ATMEGA328p LED is not blinking


Have you tried removing the programmer from the circuit and power cycling it? In some cases the programmer will hold the processor in reset or in debug mode so your program will be frozen as long as it is connected. I know I often get this state with the AVR Dragon.

You may also need to set that specific pin to GPIO use as some of the pins have alternate functions.

Check the polarity of the LED but it looks like it is good?

Also try changing the circuit so the LED is lit when sinking not sourcing. This will at least tell you whether that pin is in a Z-state (typically because it is assigned as an input) or just driving to GND all the time.

output pin <-> LED cathode
LED anode <-> resistor <-> +5V

Check for anything that could be causing an unintended interrupt that you never return from. Typically some form of default interrupt jump table should be part of every project (just in case). You might need to set up the timer to get delay_ms to work in the first place.



Jan 08, 2018 at 08:44 PM





FM Forums | Lighting & Studio Techniques | Join Upload & Sell

    
 

You are not logged in. Login or Register

Username       Or Reset password



This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.