Errata for Rev 1.0 (books bought after October 2005)
Well... nobody's perfect.
Errors in Revision 1.0
Note - for the PC_Comm program, be sure and check the
CR=CR+LF box in Br@ys Terminal.
-----------------------------------------------------
Page 18
Original--> ...AVRStudio version 4.11...
Fixed-----> ...AVRStudio version 4.09...
-----------------------------------------------------
Page 27
Original--> ...WinAVR/Samples/makefile...
Fixed-----> ...WinAVR/sample/makefile...
-----------------------------------------------------
Page 42 – Two instances:
Original--> PORTD = ~i;
Fixed-----> PORTD = i;
-----------------------------------------------------
Page 50
Original--> if(x=y) _delay_loop_2(30000) //BAD STATEMENT
NOTE: This kind of mistake is made by folks who would only want
to run the delay loop if x is equal to y, but used '=' instead of
'==' so they are not comparing x and y they are making them equal.
A too common bug. The text states that 'if(x=y)' is always true,
but there is one case where it isn't true if y is 0 then this
statement evaluates to false, so it isn't actually always true
-- which has nothing to do with the point I was trying to get across,
which is that you are assigning the value of y to x instead of
comparing the values as you should be in an 'if' statement. Clear?
-----------------------------------------------------
Page 54 and 55:
ORIGINAL:
We can set bit 3 with:
myByte = myByte & 0x08;
To see what’s happening Let’s look at these in binary:
myByte = 00000000 = 0x00
0x08 = 00001000 = 0x08
------------------------
AND = 00000000 = 0x00
Suppose myByte = 0xFF:
myByte = 11111111 = 0xFF
0x08 = 00001000 = 0x08
------------------------
AND = 00001000 = 0x08
Or maybe myByte = 0x55:
myByte = 01010101 = 0x55
0x08 = 00001000 = 0x08
------------------------
AND = 00000000 = 0x00
And maybe myByte = 0xAA:
myByte = 10101011 = 0xAA
0x08 = 00001000 = 0x08
------------------------
AND = 00001000 = 0x08
FIXED:
We can clear bit 3 with:
myByte = myByte & 0xF7;
To see what’s happening Let’s look at these in binary:
myByte = 00000000 = 0x00
0xF7 = 11110111 = 0xF7
------------------------
AND = 00000000 = 0x00
Suppose myByte = 0xFF:
myByte = 11111111 = 0xFF
0xF7 = 11110111 = 0xF7
------------------------
AND = 11110111 = 0xF7
Or maybe myByte = 0x55:
myByte = 01010101 = 0x55
0xF7 = 11110111 = 0xF7
------------------------
AND = 01010101 = 0x55
And maybe myByte = 0xAA:
myByte = 10101010 = 0xAA
0xF7 = 11110111 = 0xF7
------------------------
AND = 10100010 = 0xA2
-----------------------------------------------------
Page 55
Original--> 42 = 0x2B
Fixed-----> 42 = 0x2A
-----------------------------------------------------
Page 56
Original--> myByte = 00101011 = 0x2B
Fixed-----> myByte = 00101010 = 0x2A
Original--> OR = 01101011 = 0x6B
Fixed-----> OR = 01101010 = 0x6A
-----------------------------------------------------
Page 59
Original--> ...lower three bytes...
Fixed-----> ...lower three bits...
-----------------------------------------------------
Page 60
Original--> if(!(TCCORA & WGM01)&& !(TCCORA & WGM00))
Fixed-----> if(!(TCCORA & (1<<WGM01))&& !(TCCORA & (1<<WGM00)))
-----------------------------------------------------
Page 65
This is not an error but a warning:
The DIP Switch can interfere with the joystick so that if switch position 6 is up, the joystick push to center won't work and thus you can't access the bootloader. Make sure all the switches are down when you need to use the joystick.
-----------------------------------------------------
Page 66
Original--> Curtesty
Fixed-----> Courtesy
-----------------------------------------------------
Page 68 and 70
After: DDRB = 0x00 // set port B for input
Add: PORTB = 0xFF // enable pull up on input port
-----------------------------------------------------
Page 70
Original--> increase -= 127;
Fixed-----> increase -= 128;
-----------------------------------------------------
Page 71
Original--> delay_count = 5000 + (increase * 500)
Fixed-----> delay_count = 5000 + (increase * 476)
-----------------------------------------------------
Page 76
Original--> break:
Fixed-----> break;
Original--> …KEY_NEXT then PORTD =~0x01…
Fixed-----> …KEY_NEXT then PORTD =~0x02…
-----------------------------------------------------
Page 90
Original--> void adder(unsigned char ad1, unsigned char a1)
Fixed-----> void adder(unsigned char a1, unsigned char a2)
-----------------------------------------------------
Page 96
Original--> #elif SuprMicX = 4
Fixed-----> #elif SuprMicX == 4
-----------------------------------------------------
Page 101
Original--> char sComm[11]
Fixed-----> char sComm[13]
-----------------------------------------------------
Page 115
Original--> DDRB |= 0xD8;
Original--> PORTB |= PINB_MASK
Delete both lines
-----------------------------------------------------
Page 123
Original--> while ( !(TIFR2) && (1<<OCF2A)) );
Fixed-----> while ( !(TIFR2) & (1<<OCF2A)) );
Original--> if ( !(TIFR1) && (1<<TOV1)) );
Fixed-----> IF ( !(TIFR1) & (1<<TOV1)) );
-----------------------------------------------------
Page 126
Original--> while ( !(TIFR2) && (1<<OCF2A)) );
Fixed-----> while ( !(TIFR2) & (1<<OCF2A)) );
Original--> if ( !(TIFR2) && (1<<TOV1)) );
Fixed-----> IF ( !(TIFR2) & (1<<TOV1)) );
-----------------------------------------------------
Page 145
Original--> Optoisolator
Fixed-----> Optointerrupter
-----------------------------------------------------
Page 167
Original--> fifo
Fixed-----> lifo
Original--> ‘first in first out’
Fixed-----> ‘last in first out’
-----------------------------------------------------
Page 245
Original--> pulser3,)
Fixed-----> pulser3)
-----------------------------------------------------
Page 246
Original-->
struct pwm pulser[] = {
{ 1000, 128 };
{ 1000, 64 };
{ 4000, 25);
}
Fixed----->
struct pwm pulser[] = {
{ 1000, 128 },
{ 1000, 64 },
{ 4000, 25),
}
-----------------------------------------------------
Page 249
Original--> PORTB = (15 [note for eratta: the two < characters mess up the errata page so are omitted]
Fixed-----> PORTB = (14
And substitute 14 for 15 in the rest of the page.
And more will surely follow… especially if the reader decides to help your fellow hapless learners and email me about defects not listed here.