Errata

AVR Programming

Errata for AVR Programming

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
PDF Page XV
2nd paragraph

wrong: ...25LC256 32k SPI EEPROM chip.

correct: ...25LC256 256K SPI EEPROM chip.

(see MICROCHIP 25AA256/25LC256 datasheet:
256K SPI Bus Serial EEPROM).

Dr. Thomas Patzelt  Jul 17, 2015 
Printed Page Pages 79, 80
Figure 5-2 and Figure 5-3

The scope trace in figure 5-2 decodes to two bytes, 1001 0000 and 0101 000 that is 9 5 in decimal. The figure is incorrectly labeled "Sending 9 and 10 in Serial" as is Figure 5-3. The table in 5-3, however, is correct. The author must have entered incorrect data into the USART data buffer when generating the scope picture. So, if the scope picture was corrected the text, including on page second paragraph on page 79, would be otherwise correct.

David Comer  Sep 23, 2017 
ePub Chapter 5 Serial I/O

When using Atmel Studio 4 getting build errors from the usart.h and usart.c header files:-
i.e. dep/USART.c:5: *** missing separator. Stop.

Anonymous  Dec 14, 2017 
Printed Page 5
5

in the last line in the paragraph "I'm just hear to show you how.)" hear should be here.

Anonymous  Mar 08, 2017 
Printed, PDF Page 17
3rd paragraph of the box "Programming the AVR - What's really going on?"

In "verify again that its correct", "its" should be "it's".

Julio Tanomaru  Jun 16, 2017 
Printed Page 17
Programming the AVR box, 3rd paragraph

Replace "that its correct" with "that it's correct".

Júlio Tanomaru  Mar 03, 2019 
Printed Page 19
5th paragraph (blue letters)

wrong: ...something like C:\Program Files\avr-8-gnu-toolchain\bin

correct: ...something like C:\Program Files\avr8-gnu-toolchain\bin

Dr. Thomas Patzelt  Jul 17, 2015 
Printed, PDF Page 24
3rd paragraph

In the text "... by simply by importing the library", "by" should appear only once.

Dr. Júlio Tanomaru  Jun 17, 2017 
Printed Page 26
1st paragraph, 2nd point

wrong: See "portpins.h and the Arduino IDE" on page 26.

correct: See "portpins.h and the Arduino IDE" on page 27.

Dr. Thomas Patzelt  Jul 17, 2015 
Printed Page 26
2nd

See "portpins.h... " on page 27 rather than 26

Remuar  Oct 18, 2015 
Printed Page 27
In the section: Wiring your Arduino as a flash programmer

The configuration doesn't work for the Arduino UNO beacuse somehow the
arduino is reset when avrdude tries to talk to the avr168. Avrdude reports
error "*avrdude: stk500_getparm(): (a) protocol error, expect=0x14,
resp=0x14"*
The solution is to insert a 10uF cap between reset and ground on the uno
when using it as an ISP, see https://www.arduino.cc/en/Tutorial/ArduinoISP

Anonymous  Jan 12, 2016 
Printed Page 30
6th paragraph

Atmel AVRISP mkII ...

There`s nothing wrong with this paragraph, but there`s missing a very, very important note which can be found in ATMEL's AVRISP MkII introduction (see: http://www.atmel.com/webdoc/avrispmkii/avrispmkii.intro_connecting.html):

The AVRISP mkII does not provide power on the Vcc pin, but uses this pin to sense the voltage on the target circuitry. Your circuit needs to be powered by external means to operate.

Dr. Thomas Patzelt  Aug 06, 2015 
Printed Page 30
6th paragraph

Under the paragraph heading "Flash Programmers I Have Known and Loved," the Atmel AVRISP mkII recommended as the "current official USB programmer" is obsolete as of the end of 2015. No direct replacement is advertised on the Atmel site.

Peter Middleton  Feb 01, 2016 
PDF Page 36
ARVDude Options, -U item

Missed the word "is" after "This".

Dr. Júlio Tanomaru  Jun 24, 2017 
PDF Page 36
Second paragraph of the "AVRDUDE errors" section

"an an error" should be "an error".

Dr. Júlio Tanomaru  Jun 24, 2017 
Printed Page 39
4th to 6th topic: MAIN, LOCAL_SOURCE, EXTRA_SOURCE and EXTRA_SOURCE_FILES

In the ZIP file from github/hexagon5un/AVR-Programming the makefile in the folder Chapter02_Programming-AVRs/blinkLED/ does not contain the word MAIN. I suppose in the file is written TARGET.
It also doe not contain the words LOCAL_SOURCE, EXTRA_SOURCE, and EXTRA_SOURCE_FILES.
I think for a beginner this is very irritating, especially in this early stage of her or his progress.

Henning Plumeyer  Mar 26, 2015 
Printed Page 48
Paragraph beginning with "When you..."

The explanation is conceptually wrong, because it mixes things that the compiler does (at compiling time) with things the CPU does (at runtime). We could write something like this:

... the compiler picks a free slot from the chip's available RAM, replaces anyreference to "a" by that slot's memory address, and generates code to store the value 7 there. Later on, when you add one to your variable (by executing a = a + 1;), the CPU pulls the value out of the memory slot...

Júlio Tanomaru  Mar 08, 2019 
Printed Page 54
1st paragraph

wrong: ... AVR pins ... PD0 ... PD1 ... PD5 ... PD6 ... PD7...

correct: ... AVR pins ... PB0 ... PB1 ... PB5 ... PB6 ... PB7...

(see page 53, last paragraph: all hooked up to the pins PB0 through PB7 on the AVR.)

Dr. Thomas Patzelt  Jul 17, 2015 
PDF Page 55
Last paragraph

"main() functions" should be "main() function".

Dr. Júlio Tanomaru  Jun 25, 2017 
PDF Page 56
End of third paragraph

"in it's definition" should be "in its definition".

Dr. Júlio Tanomaru  Jun 25, 2017 
Printed Page 80
1st full paragraph

It would be worth drawing a schematic of the Alice/Bob serial communication situation. Granted, I usually have to look up pull-up resistors and pull-down resistors to make sure I get it right, however, this situation is still a little ambiguous.

There is no mention of a microcontroller so I cannot assume that there is a path to ground through an mcu IO pin. The way I interpret the situation so that it follows and works with the text is as follows:

There is a VCC of 5 Vdc. Connected to this is the pull-up resistor in series with an LED for which the cathode is connected to ground. Connected to the anode is one side of a normally open pushbutton switch. The other end of the normally open pushbutton switch is connected to ground. This way, when the NOPB is pressed, it provides a path to ground, thus turning off the LED.

One more point, I know this book is for a little bit of more advanced that many books for something like the Arduino. I expect to work a little more to figure out how things are working that are not immediately apparent.

Anonymous  May 12, 2016 
Printed Page 147
1st paragraph

In first line of 1st paragraph: 'and then AND in your desired channel number'
Should be 'and then OR in your desired channel number'

Darrel Dronet  Jun 10, 2021 
Printed Page 155
External Interrupts 101: Real-time Button Pressing Examples

While the example is nice to explain reacting on events in real-time using interrupts, I think it should be pointed out to beginners like me that a button should normally not be connected to an interrupt as Jack Ganssle writes in his "Guide to Debouncing".
Readers could even be tempted to debounce their button using the delayed button state rechecking in the ISR as I did, which is not a good idea and didn't work well.
Checking the state of the button connected to an input pin in a timer interrupt ISR every n ms seems to be a solution recommended by many, and it works very well for me.

So maybe beginners like me could be made aware of that?

Torsten Römer  May 03, 2015 
PDF Page 168
Around Example 8-2

Hello,

This is a suggestion for an aside that could be included in the book. In Example 8-2 (capSense.c listing), chargeCycleCount is a 16 bits (2 bytes) unsigned integer. However, the AVR used in the book is an 8 bit processor, which means that updating or reading a 2 bytes variable requires 2 memory operations (one for each 8 bit word).

The book is correct that the variable must be marked volatile. In this particular case, the example is correct since the event loop cannot read chargeCycleCount and be interrupted by the ISR which increments it. The global interrupt flag is in fact disabled at the time the event loop reads chargeCycleCount (cli() has been called before).

However, I believe it would be great to warn in an aside about the potential race condition inherent to modifying and reading a variable longer than 8 bits concurrently in an interrupt handler and in the event loop even if it is volatile. Suppose the interrupts were not disabled at the time chargeCycleCount is read, the least significant byte of chargeCycleCount could be read, and then the event loop could be interrupted by the ISR which modifies both bytes of chargeCycleCount. Now, when execution returns to the event loop, it reads the most significant byte of chargeCycleCount.

Here is the problem, the value of chargeCycleCount as seen by the event loop is made of half the previous value and half the new value, which may cause undesired behaviours. This is called a torn read.

It would be great to explain why in Example 8-2 the sei() and cli() calls are very important.

Thank you

Jean-Francois Leblanc-Richard  Sep 12, 2015 
Printed Page 169
Fritzing image of breadboard

The breadboard does not show AVcc connected...without it connected to power, the pins on Port C will not work.
The layout should be updated to show power (decoupled) to AVcc.

Anonymous  Dec 14, 2016 
Printed Page 185
Table 9-1

Clock tick time for 1 MHz CPU with 256 Prescale should be 0.256 milliseconds (my copy has 2.56 milliseconds).

Darrel Dronet  Jun 12, 2021 
PDF Page 190
2nd Paragraph

The paragraph contains a link saying “Burning Fuses: Enabling the High-Speed CPU Clock” which points to page 190. The “Burning Fuses: Enabling the High-Speed CPU Clock” topic is found on page 191.

Jan Ray  Jun 14, 2015 
Printed Page 192
3rd paragraph

Change DIV8 to CLKDIV8.

Júlio Tanomaru  Mar 08, 2019 
Printed Page 201
Last paragraph

The PWM frequency for 8 MHz CPU clock and 8-bit audio mentioned is 32.5 kHz, while I think it should be 8 MHz / 2^8 = 31.25 kHz.

The paragraph refers to Chapter 13, on page 276 there is a box "Sample Rate" where also the PWM frequency is calculated for 8 MHz CPU clock and 8-bit with the result of 31,250 Hz.

Torsten Römer  Apr 10, 2015 
Printed Page 231
Code section at top of page

I'd feel better if:

if (ticks == OVERFLOWS_PER_SECOND)

were:

if (ticks >= OVERFLOWS_PER_SECOND)

I understand that if you missed just the right ticks update, you'd only be off by about a second until the value overflowed and cycled to top again. I'd still be concerned that the while loop itself or pollSerial() (even if there was no waiting data) might cause an occasional ticks overshoot.

This is just a quibble. What the author wrote is clearer and doesn't require extra explanation. And as the author also notes, you are not going to get atomic clock accuracy out of this.

Darrel Dronet  Jun 14, 2021 
PDF, ePub Page 249
In the comments of the example 12-1 code listing

Where it says "Measure either AVCC of the voltage on AREF" I think it should read "Measure either AVCC or the voltage on AREF".

Thomas Weisbach  Mar 20, 2015 
Printed Page 263
code lowValue condition

Current logic the highValue is adjusted when the adcValue is strictly greater than ewma middle value and similarly, the lowValue is adjusted when the adcValue is strictly less than ewma middle value.

I think that the lowValue should be adjusted when the adcValue is less than or equal to the ewma middle value. I've been running into case where adcValue equals ewma middle value. But this passes through without adjusting highValue or lowValue. Can cause lowValue to not correct toward middle value.

before:
if(adcValue < (middleValue >> 4))

after
if(adcValue <= (middleValue >> 4))

I've got a few graphs if this that might help show the case a little better if necessary.

Bruce W. Lowther  Nov 19, 2016 
Printed Page 292
Sidebar "Selecting the Base Resistor" 2nd paragraph 3rd sentence

please change
Because you gain is 100,
to
Because your gain is 100,

Henning Plumeyer  Mar 26, 2015 
Printed Page 293
Sidebar: "Double Up for Double Current", last line last paragraph.

Change batter:

"to batter manage your current load"

to better:

"to better manage your current load"

Darrel Dronet  Jun 16, 2021 
PDF Page 343
4th paragraph in highlighted box

Search for "wiring up the output of the eigth bit of the first reg-
ister"

eigth should be eighth.

MrFabulous  Jun 14, 2016 
Printed Page 344
7th paragraph, (EEPROM) 2nd line

Change 'it':

'...though, it that EEPROM is...'

to

'...though, is that EEPROM is...'

Darrel Dronet  Jun 23, 2021 
Printed Page 352
25LC256 example

A mention of the write protection modes on the 25LC256 may be warranted. The chips I used came with BP0 and BP1 set by default, hence all write operations fail silently and the example did not work on the new chips without first doing a Write Status Register Instruction transfer and pushing both bits low. As these bits are non-volatile this need only be done once, however it may save hours of troubleshooting for new users not familiar with the chip.

Michael E  Dec 22, 2014 
Printed Page 367
In the sample code 17.2, the first comment.

The comment in the code says "see p. 242", but 242 is a blank page.

Ken Johansen  Dec 12, 2015 
Printed Page 369
in main()

The i2CThermometer.c program displayed garbled output in the serial screen. Changing the serial port speeds made no difference. Although I was able to read the lm75 data in a Logic Analyser, while running the program.

When I commented out the clock_prescale_set(clock_div_1) statement or modified the parameter to clock_div_8, the serial output was Ok.

The same problem & solution applied for p373, the loggingThermometer.c program.

I used an ATMega328, is that the reason why? I did try another but still the same result. Is it because of the AtMega328 & not ATMega128? And if so any idea why??

Regards



rod  Aug 24, 2015 
Printed Page 369
i2c thermometer demo

The garbled output is fixed by using avrdude to set the full-speed clock. ie lfuse=E2
or by using the supplied makefile, run
make set_fast_fuse
(or see p191).

rod  Sep 08, 2015 
Printed Page 370
void initI2C

set bit rate calculation 8Mhz / (16+2*TWBR*1) doesn't give 100kHz but 13.9Hz

reference to p 242 doesn't help further

Pierre Maurer  Feb 19, 2021 
Other Digital Version 448
voltmeter.c program

I think there are two problems with the voltmeter program:

1. The division does not correctly round the value. It should be something like this:

#define ADC_BITS_EXTRA 2 // extra 2 bits required (10 + 2 total)
#define ADC_AVERAGES (1 << (2 * ADC_BITS_EXTRA)) // ADC values to accumulate
#define ADC_ROUND_CNST (1 << (ADC_BITS_EXTRA - 1)) // round-off constant
...
// ADC oversampling
adc_value = 0;
for (i = 0; i < ADC_AVERAGES; ++i) {
sleep_mode();
adc_value += ADC;
}
adc_value = (adc_value + ADC_ROUND_CNST) >> ADC_BITS_EXTRA;
...

2. The voltage scaling seems wrong. The maximum possible obtained integer value is 4092, that is, 0b111111111100. The program uses 4096.

Jan Hrabe  Jan 09, 2017