avr-chat
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-chat] avrdude-Problems


From: Erik Christiansen
Subject: Re: [avr-chat] avrdude-Problems
Date: Sat, 12 Apr 2014 16:08:31 +1000
User-agent: Mutt/1.5.21+145 (2a1c5d3dd72e) (2012-12-30)

On 11.04.14 16:31, address@hidden wrote:
> As a board I soldered a power supply with three 1.5V batteries and a
> capacitor of 47microFarad, to plan the voltage, inbetween the GND/4.5V
> and a seperate part consisting of a LED-Diode (the side where a part
> is cut off towards PD1) and a resistor (470ohm) combined serial, with
> one end to 4.5V and one end to PD1, and a push-button between 4.5V and
> PD2 (the aim of the program is to be able to turn on/off the LED by
> pushing the button).

Try connecting the push-button between PD2 and ground, and enabling
PD2's internal pull-up resistor or adding an external one, e.g. 10k.
Currently, you have nothing to pull PD2/INT0 low. (It is unaffected by
gravity. ;-)

Understand also that once wiring and programming are fixed, the LED will
light or not, apparently randomly, due to contact bounce. I.e. each
push-button depression generates several make/break cycles, referred to
as "contact bounce". The interrupt line detects them all, and will flip
the LED state on each bounce, once it's working.

A more predictable "Hello World" experiment is to toggle the LED, using
a software timing loop, using several registers to build up a long
count, e.g. in the vicinity of one second.

> Additionaly I connected the RESET-pin to 4.5V to avoid a reset.

The reset line must be able to be pulled to ground during programming,
so hopefully that connection is through something like a 10k resistor,
or your programming will always fail. (See section "26.8 Serial
Downloading" in the datasheet.)

> Well, when I connected the power supply (4.5V as well to ARef and
> AVcc) to the rest nothing happened. The voltage was fine, except the
> part, where the microcontroller should have worked: neither the LED
> nor the push-button had any voltage.

If there is no +4.5v on the LED, then PD1 going low will do nothing,
obviously. I expect you will have fixed these very simple wiring faults
by now.

> Afterwards I read the flash-memory with the help of AVRFuses to check
> wether programming had really worked. It took a long time until
> completion and when I checked the .hex-file (see Try1.hex) it was
> different to what I had progammed...

What are you using to program the device? If it were avrdude, it would
automatically perform that verification, and immediately warn on any
mismatch. Until programming verifiably succeeds, any LED blinking lies
in the land of ambition.

Code changes are then needed, since your program leaves INT0 disabled.

> After several trys and checkings I had to forfeit... Once again I
> would be most grateful if you could help me!

As already advised, it is necessary to download a datasheet from the
Atmel website. The copy of the ATmega48_88_168 datasheet, which I once
downloaded, shows which bit of EIMSK needs to be set before INT0 is
enabled. It also describes the effect of the default state of EICRA on
the interrupt input, and how you could change the behaviour.

The sheer volume of data (361 pages) in the datasheet reveals that a
little time and effort needs to be set aside for climbing that early
steep part of the learning curve. After a few basics are understood, the
reward for effort improves. Do not be discouraged by initial stumbling.

Erik

-- 
What is wanted is not the will to believe, but the will to find out,
which is the exact opposite.
                           - Bertrand Russell, _Sceptical_Essays_, 1928




reply via email to

[Prev in Thread] Current Thread [Next in Thread]