Solution Manual For AVR Microcontroller and Embedded Systems: Using Assembly and C Muhammad Ali Mazidi, Sarmad Naimi, Sepehr Naimi
Solution Manual For AVR Microcontroller and Embedded Systems: Using Assembly and C Muhammad Ali Mazidi, Sarmad Naimi, Sepehr Naimi
Solution Manual For AVR Microcontroller and Embedded Systems: Using Assembly and C Muhammad Ali Mazidi, Sarmad Naimi, Sepehr Naimi
https://testbankmall.com/product/solution-manual-
for-8051-microcontroller-and-embedded-systems-the-2-e-2nd-
edition-muhammad-ali-mazidi-janice-g-mazidi-rolin-d-mckinlay/
https://testbankmall.com/product/solutions-manual-to-accompany-
pic-microcontroller-and-embedded-systems-1st-edition-0131194046/
https://testbankmall.com/product/solution-manual-for-signals-and-
systems-using-matlab-3rd-by-chaparro/
https://testbankmall.com/product/solution-manual-for-data-
structures-and-problem-solving-using-c-2-e-mark-a-weiss/
Signals and Systems Analysis Using Transform Methods
and MATLAB 3rd Edition Roberts Solutions Manual
https://testbankmall.com/product/signals-and-systems-analysis-
using-transform-methods-and-matlab-3rd-edition-roberts-solutions-
manual/
https://testbankmall.com/product/solution-manual-for-data-
structures-and-other-objects-using-c-4-e-michael-main-walter-
savitch/
https://testbankmall.com/product/solutions-manual-to-accompany-
fundamentals-of-signals-and-systems-using-the-web-and-matlab-3rd-
edition-9780131687370/
https://testbankmall.com/product/solution-manual-for-analog-
signals-and-systems-by-kudeki/
https://testbankmall.com/product/solution-manual-for-assembly-
language-for-x86-processors-7-e-7th-edition-kip-r-irvine/
18. EEPROM does not lose its data when power is off, whereas SRAM does. So, the
EEPROM is used for storing data that should rarely be changed and should not be lost
when the power is off (e.g., options and settings); whereas the SRAM is used for storing
data and parameters that are changed frequently.
19. Yes
20. No, each microcontroller should have general purpose registers and I/O registers.
21. From $60 to $FFFF
22. 65,536 bytes
25.
LDI R16, $5F
OUT PORTB, R16
26. True
27.
LDI R30, $11
STS $100, R30
STS $101, R30
STS $102, R30
STS $103, R30
STS $104, R30
STS $105, R30
28.
LDI R30, $11
STS $100, R30
STS $101, R30
STS $102, R30
STS $103, R30
STS $104, R30
STS $105, R30
29.
30.
31.
LDُ
S
ُ R27, $68
32. COM R27
LDُ
S
ُ R19, $68
OUT PORTC, R19
SECTION 2.4: AVR STATUS REGISTER
33. 8
34. 0, 5
(b)
$00 0000 0000
+ $FF 1111 1111
$FF 1111 1111 R23 = $FF
C = 0 because there is no carry beyond the D7 bit.
(c)
$FF 1111 1111
+ $05 0000 0101
$FF 10000 0100 R30 = $04
C = 1 because there is a carry beyond the D7 bit.
40.
LDI R16, $55
LDI R20, $55
ADD R16, R20
ADD R16, R20
ADD R16, R20
ADD R16, R20
ADD R16, R20
55. 0
56. It executes whatever is at location 0 which could be garbage in this case.
57. a) 2 bytes b) 2 bytes c) 2 bytes d) 2 bytes
e) 2 bytes f) 2 bytes g) 2 bytes h) 4 bytes
58. (a)
LDIُR20,‘1’
STS 0x100, R20
LDIُR20,‘9’
STS 0x101, R20
LDIُR20,‘5’
STS 0x102, R20
LDIُR20,‘1’
STS 0x103, R20
LDIُR20,‘2’
STS 0x104, R20
(b)
LDI R19,0
LDS R16, 0x100
ADD R19,R16
LDS R16, 0x101
ADD R19,R16
LDS R16, 0x102
ADD R19,R16
LDS R16, 0x103
ADD R19,R16
LDS R16, 0x104
ADD R19,R16
STS 0x306, R19
(c)
59. In AVR, each location of the program memory holds 2 bytes; therefore:
a) Memory locations = 32 K / 2 = 16 K = 16 * 1024 = 16384 Î Last location = 16383
= $3FFF
65. 2 bytes
66. 2 bytes
67. As shown in Figure 2-14, 8 bits are set aside for K. Therefore, K can be between 0 and
255.
68. $0C01 = 0000 1100 0000 0001. According to the figures of page 92, it is the machine
code for the ADD instruction.
69. It is a 4-byte instruction. 16 bits of it are set aside for K. Therefore, K can be between 0
and 65535. In AVR, the data memory is 64 KB; as a result, STS can address the entire
memory space.
70. It is a 4-byte instruction. 16 bits of it are set aside for K. Therefore, K can be between 0
and 65535. In AVR, the data memory is 64 KB; as a result, LDS can address the entire
memory space.
71. In the JMP instruction, 22 bits are set aside for K. Therefore K can be between 0 and
4,194,303.
72. RISC is reduced instruction set computer; CISC stands for complex instruction set
computer.
73. CISC
74. RISC
75. RISC
76. CISC
77. False
I had thought it necessary to keep watch during this first night, for
the protection of my family. Every leaf that stirred, gave me the
apprehension that it was the approach of a jackall or a tiger, who
might attack some member of my family. As soon as one of the
heaps was consumed, I lighted another; and at length, finding that
no animal appeared, I by degrees became assured, and at last fell
into so sound a sleep, that I did not awake early enough for the
execution of my project for that day. The boys were all up and about
me. We took our breakfast, and fell to our work. My wife, having
finished her daily occupation of milking the cow, and preparing the
breakfast for the family, and for all the animals, set off with Ernest,
Jack, and Francis, attended by the ass, to the sea-shore; they had
no doubt of finding some more pieces of wood, and they thought it
would be prudent to replenish our exhausted store. In her absence, I
ascended the tree with Fritz, and made the necessary preparations
for my undertaking, for which I found it in every respect convenient;
for the branches grew extremely close to each other, and in an
exactly horizontal direction. Such as grew in a manner to obstruct my
design, I cut off either with the saw or hatchet, leaving none but what
presented me with a sort of foundation for my work. I left those which
spread themselves evenly upon the trunk, and had the largest circuit,
as a support for my floor. Above these, at the height of forty-six feet,
I found others, upon which to suspend our hammocks; and higher
still, there was a further series of branches, destined to receive the
roof of my tent, which for the present was to be formed of nothing
more than a large surface of sail-cloth.
The progress of these preparations was considerably slow. It was
necessary to raise certain beams to this height of forty feet, that
were too heavy for my wife and her little assistants to lift from the
ground without great effort. I had, however, the resource of my
pulley, which served to excellent purpose. My wife and her little boys
fastened the beams to pieces of cord above, while Fritz and I
contrived to draw them up to the elevation of the tent one by one.
When I had already placed two beams upon the branches, I
hastened to fix my planks upon them; and I made my floor double,
that it might have sufficient solidity if the beams should be in any way
warped from their places. I then formed a wall something like a park-
paling, all round, to prevent accidents to ourselves or children. This
operation, and a third journey to the sea-shore to collect the timber
necessary, filled our morning so completely, that not one of us had
thought about dinner. For this once it was requisite to be content with
a simple provision of ham and milk. Dinner ended, we returned to
work to finish our aërial palace, which now began to make an
imposing appearance. We unhooked our hammocks, &c. from the
projecting roots from which they had at first been suspended; and,
by means of my pulley, contrived to hoist them up to our new
habitation. The sail-cloth roof was supported by the thick branches
above; and as it was of great compass, and hung down on every
side, the idea occurred to me of nailing it to the paling on two sides,
and thus getting not only a roof, but two walls also; the immense
trunk of the tree forming a third; while a fourth side contained the
entrance of our apartment; and this I left entirely open, both as a
means of seeing what passed without, and for admitting a current of
air to cool us in this burning temperature. We also on this side
enjoyed an extensive and uninterrupted view of the vast ocean, and
its lengthening shore. The hammocks were soon suspended from
the branches above, and now every thing was ready for our
reception that very evening. Well satisfied with the execution of my
plan, I descended with Fritz, who had assisted me throughout the
whole; and as the day was not far advanced, and I observed we had
still some planks remaining, we set about contriving a large table to
be placed between the roots of the tree, and surrounded with
benches; and this place, we said, should be called our dining-
parlour. For this time, we performed our task but slightly, for I
confess I was much fatigued. The table, on the whole, however, was
such as might be well endured, and the view of it gave my wife
considerable satisfaction as she looked on, busied with preparations
for our supper. In the mean time, the three youngest boys collected
all the pieces of wood we had thrown down from the tree, and put
them together to dry in a heap, at a small distance from our fire-
place. I also tied together a quantity of small wood which we had
collected, and which served to augment our store for making fires.
Entirely exhausted by the fatigues of the day, I threw myself at full
length on a bank, saying to my wife, that as I had worked like a
galley-slave to-day, I should allow myself some rest to-morrow. My
wife answered, that not only I was entitled to a day of rest, but that it
was a duty incumbent on me to take it on the following day; for, said
she, I have calculated that to-morrow is Sunday. Unfortunately we
had already passed one sabbath-day without recollecting that it was
so.
Father.—I thank you, my dear, for making this discovery, and I
promise you that the day shall be celebrated by us, as it ought to be.
It was not unknown to me that we had passed over one Sunday
without a due observance of the duties it imposes; but I confess it
appeared to me, that being caused by the extraordinary exertions we
had to make for the preservation of our lives in a desert place, to
which it had pleased God to conduct us, it was a pardonable
omission; but now that we seem to have surmounted many
difficulties, and to have secured ourselves an habitation, we should
indeed be culpable not to celebrate in a solemn and particular
manner, the day he has consecrated to himself.
My Wife.—Be assured, my dear, that I shall heartily join you in
rendering thanks to God, who in so imminent a danger preserved all
that was dear to me, and affords us here, in a strange and desert
land, not only the necessaries of life, but many of its comforts also. I
could no where have met with an habitation more to my fancy, than
that you have effected for us in the tree. I will mount the ladder this
evening with you, for I feel almost a child’s joy at the idea of passing
the night up in the air, as we may call it. Let us quickly eat our supper
and go to bed, without dropping a word about its being Sunday to-
morrow. It will be a great pleasure to me to surprise the boys with the
news of a day of rest from labour, which they did not expect.
And I, for my part, said I, am rejoiced to find you thus contented
and resigned to your fate, and entertaining no contempt for our
imperfect contrivances. But now let us see what you have prepared
for our reward; and let us call the children round us; I feel in want of
such a restorative after my fatigue.
The little company was soon assembled round the table. Their
mother followed, holding in her hand an earthen pot, which we had
before observed upon the fire, and the contents of which we were all
curious to be informed of. She took off the cover, and with a fork
drew out of it the flamingo which Fritz had killed. She informed us
that she had preferred dressing it this way, to roasting, because
Ernest had assured her that it was an old bird, which would prove
hard and tough, and had advised her to improve it by stewing. We
rallied our glutton boy on this foible of his character, and his brothers
gave him the name of the cook. We, however, had soon reason to
know, that he had conferred upon us an important obligation; for the
bird, which roasted we perhaps should not have been able to touch,
now appeared excellent, and was eaten up to the very bones.
While we were thus enjoying our repast, the live flamingo stalked
up to the place where we were sitting, in the midst of our flock of
fowls, to receive his part of the repast, little thinking that it was his
late companion that had furnished it. The live flamingo had now
become so tame, that we had released him from the stake. He took
his walks gravely from place to place, and looked perfectly contented
with his company. His fine plumage was a most pleasing sight; while,
on the other hand, the sportive tricks and the grimaces of our little
monkey, afforded the most agreeable spectacle imaginable. The little
animal had become quite familiar with us; jumped from the shoulder
of one to that of another; always caught adroitly the meat we threw
him, and ate it in so pleasant a way as to make us laugh heartily. To
increase our merriment, the old sow, which hitherto had shown an
unconquerable aversion to our society, and which we had missed for
two whole days, was now seen advancing towards us, grunting at
every step. For this time, however, her grunting indicated her joy at
having found us once more: and the joy was mutual; of which my
wife gave her a substantial proof, by serving her instantly with what
remained of our daily allowance of milk.
I confess I thought her a little too generous, till she explained to
me that it was necessary to contrive some utensils proper for making
butter and cheese, and that till this was done, it was better to turn the
milk to profit in this way, than, in so hot a climate, to let it be spoiled.
And it was the more necessary, she added, as our grain began to
run short, and that, as pigs are very fond of milk, it might be a means
of preventing her wandering from us again.
I always find you right, my dear, said I. It shall not be long ere we
again undertake another visit to the vessel, to fetch a new provision
of grain for your poultry.
Again the subject of the vessel, said she, with a sort of reproachful
regret; I shall never enjoy a moment’s happiness till it is gone to the
bottom, and you shall have entirely banished it from your thoughts!
You never make a voyage that does not leave me filled with
agonizing alarm for your safety.
I cannot deny, replied I, that there may be some reason for this;
but I must remind you that we always choose a day of calm and
settled weather for our excursion; and in my opinion we should be
unpardonable, if we allowed ourselves to be so subdued by
causeless alarms, as to neglect the means of obtaining a variety of
useful things, which Providence seems to have reserved for our use.
During this conversation, the boys, by my direction, had lighted
one of the heaps of wood for the protection of our animals. This
being done, we tied long ropes loosely round the necks of our dogs,
purposing to mount to our tent with the ends in my hand, that I might
be able to let them loose upon the enemy at the first barking I should
hear. Every one was now eager to retire to rest, and the signal for
ascending the ladder, was given. The three eldest boys were up in
an instant; then came their mother’s turn, who proceeded slowly and
cautiously, and arrived in perfect safety. My own ascension was the
last, and the most difficult; for I carried little Francis on my back, and
the end of the ladder had been loosened at the bottom, that I might
be able to draw it up in the tent during the night: every step,
therefore, was made with the greatest difficulty, in consequence of its
swinging motion. At last, however, I got to the top, and, to the
admiration of the boys, drew the ladder after me. It appeared to them
that we were in one of the strong castles of the ancient chevaliers, in
which, when the draw-bridge is raised, the inhabitants are secured
from every attack of the enemy. Notwithstanding this apparent safety,
I kept our guns in readiness for whatever event might require their
use. We now abandoned ourselves to repose; our hearts
experienced a full tranquillity; and the fatigue we had all undergone,
induced so sound a sleep, that day-light shone full in the front of our
habitation, before our eyes were opened.
CHAPTER XII.
The Sabbath and the parable.