tutorial to read AVR datasheet for beginner

Go To Last Post
24 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi

Does anyone come cross a tutorial on how to read AVR datasheet?

I seem to be lost every time I try to make sense of it, or try to learn how to use a register.

thanks

Zhuhua Wu - Electronic Engineering Student

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The average datasheet has a number of sections. Having a degree in electronics engineering does help. What specifically do you have trouble interpreting? There are tutorials on specific peripherals of the AVR like the timers, uart ,adc etc in the tutorial section.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In opposition to most others, the AVR datasheets are excellent. :!:

All informations are inside a single document.

Every section contain a verbose description and a short register description on the end.

Peter

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Most datasheets also have a condensed version of only fifteen-twenty pages, which is a bit easier to digest than the three or four hundred pages in the whole thing. It doesn't go into details but does indicate the facilities available on the chip and might give you pointers to your area of interest.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For the OP I suggest that you take one specific data sheet, and one specific section, and try to read it. Then, when questions arise pose them here at AVRfreaks.

Make sure you give the background information when asking, e.g. spelling out exatly what dta sheet and section you are reading. Then tell, in a consie way, what you have understood. Then explain or point to what you do not understand.

Unless you have other special interests I would suggest starting with the simples timer section (typically one of the 8-bit timers). Just browse though it for a few minutes to get a grip of what sub-sections it contains. Then start reading the section from the beginning, slowly and carefully.

I still prefer paper for such reads, so that I can mark, underline, make notes in the margin, attach yellow post-it's to pages I return to often etc. While computers are great, the inention of paper and pen is proven over thousands of years. There must be something right with it.. :D

Yes, reading a data sheet for the first time can be a daunting task. The section for just one of the timers can easily be 40 pages. But there is no way around it - if you want to master AVRs you must learn to read such things. Be ambitious, and be clear and to the point when asking qestions, and people here will definitively help you get through your first reads.

It's a bit like learning to ride a bike. Not easily explained, an no matter how much someone else tells you how to do it you can not actually learn it unless you get on it and try for yourself. You will fall and get bruises several times. That is expected, and part of the learning process.

I concur with Danni: Atmel AVR data sheets are generally excellent, with few errors, fairly complete in information, very good structure etc.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think the point is that you don't have to read/understand everything on day one. I'm happy to be able to say that in all the AVR datasheets I've ever looked at I have never yet been moved to read whole chapters on any of: Two Wire Serial Interface, Analog Comparator, JTAG Boundary Scan, Memory Programming, Electrical Characteristics, Typical Characteristics because none of those subjects interest me in the slightest.

I guess the converse of that is that the chapters I have read completely then repeatedly dipped into again and again are the ones on timers, IO, UART, Power management, Clock sources, ADC.

But there's no definite order or particular bits you should/shouldn't study - just read the chapters on the peripherals you are interested in using and the overall architectural chapters on memories, clock sources and so on that will concern you however you plan to use the chip.

Quote:

I concur with Danni: Atmel AVR data sheets are generally excellent

+1, far better than the muddled data from many vendors.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

thanks guys, I always get great help from the community, that's why I like AVR chips.

The area I want to learn is to find out what bit to set to do a certain job. say I want to Initial ADC and using it, that's one of the area I will get lost.

I am learning timer/ADC/PWM etc at the moment, I mean I can always google and copy and paste some code to do get the job done for a popular chip.

But I really want to be able to read the datasheet and find out what bit to set myself, that make me feel I am actually learning it, not just copy and paste.

This post is intended to ask "how to read data sheet in general",I guess I will start a new post when I come across specific chip/area that I need to understand.

Thanks again.

Zhuhua Wu - Electronic Engineering Student

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

bug13avr wrote:
But I really want to be able to read the datasheet and find out what bit to set myself, that make me feel I am actually learning it, not just copy and paste.
I'm an EE and been doing this for decades. When I'm approaching a new task that requires figuring out how to set the AVR registers I always do an Internet search, find some code, copy, paste, and test. Then I revere engineer the bit settings by comparing what is actually done in a working example to what he data sheet says. It is fairly rare for me to just go straight to the datasheet and try to figure it out. Life's too short and there are plenty of tested examples to learn from.

Smiley

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ditto on being a long-time EE. My strategy is similar to Smiley's. I look for some code that will carry out a task at least somewhat similar to what I am trying to do.

Then, its analysis time. I tend to do "synthesis by analysis". Dissect the code. Try to figure out why it was done the way it was. How does that code deal with bits? With timing (that is, order of things)? Interrupts? Why do they turn interrupts on or off in strange spots? String I/O? And on, and on, and on.

It never ends. There is still a LOT that I am not terribly confident about. Use of pointers in C, for example. Output streams in C for example.

So, don't get hung up about understanding everything all at once. There is no one blinding flash by which you are totally enlightened, It comes in a bunch of little sparks that add up over time.

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Also being an EE, I do a mix....

Remember that the AVR8 bit datasheets are very good and complete.

If I need to set-up for instance the ADC, then I go to the registers part of that section. I read through the registers description and try to understand what the different bits are doing. If there is a lot to set, then I might be tempted to go for examples, for instance with the timers where you have a lot of configurations possible.
If my code does not work I will go and search for examples to see where I went wrong.
The big advantage of the avrs is that the io blocks all use the same regisers and most of them even have the same bit set-up, so learning on one part will be much quicker on a second part.
and as even the experts need to check a datasheet, then you should not be embarrassed to have to look in it regularly.

Have fun in learning

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

smileymicros wrote:
Then I revere engineer the bit settings
Would that be one bit by C, two bits by assembler ?

Sorry Joe (I know you don't like going off topic), but that had to be the best typing mistake I have seen all year and a near perfect segue for my feeble talents. Thanks.

Cheers,

Ross

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Strange.. Am I alone in actually reading applicable sections of the data sheets upon need? (Not only the register and bit sections, but also (some of) the descriptive text.)

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Strange.. Am I alone in actually reading applicable sections of the data sheets upon need?
No, all Swedes do that.
AVR's Datasheets are quite nice compared to other brands.
I always use the Datasheet for setting up registers.
Since I'm a freakin' assembler guy code examples are rare and I've gotten used to solve it on my own.
Which possibly deepens my knowledge on the subject.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

JohanEkdahl wrote:
Strange.. Am I alone in actually reading applicable sections of the data sheets upon need? (Not only the register and bit sections, but also (some of) the descriptive text.)

I do that when I do not understand the descriptive texts in the registers section.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Lennart wrote:
Quote:
Strange.. Am I alone in actually reading applicable sections of the data sheets upon need?
No, all Swedes do that.
AVR's Datasheets are quite nice compared to other brands.

Now I trully know what my heritage is. :wink:

I even print the applicable sections to be able to read them while on the go*.

+1 on Atmel datasheets.

* You figure it out.

"I may make you feel but I can't make you think" - Jethro Tull - Thick As A Brick

"void transmigratus(void) {transmigratus();} // recursio infinitus" - larryvc

"It's much more practical to rely on the processing powers of the real debugger, i.e. the one between the keyboard and chair." - JW wek3

"When you arise in the morning think of what a privilege it is to be alive: to breathe, to think, to enjoy, to love." -  Marcus Aurelius

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
I even print the applicable sections to be able to read them while on the go*.
[...]
* You figure it out.

My prude-ness, and the new forum policies, forbids me to do the obious mis-spelling joke on "data sheet" here. You figure it out..

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

valusoft wrote:
smileymicros wrote:
Then I revere engineer the bit settings
Would that be one bit by C, two bits by assembler ?

Sorry Joe (I know you don't like going off topic), but that had to be the best typing mistake I have seen all year and a near perfect segue for my feeble talents. Thanks.

Cheers,

Ross

:D

Actually it is all by C, but I do my programming in an old North Church tower, lighting the path for stopping invaders everywhere...

And BTW not to be misunderstood, (oh dear God please don't let me be...) I of course read the datasheets also, it is just the I look for known good examples first which helps me to understand what is really needed from the data sheet.

And for you guys claiming to read the data sheet, are you saying that is exclusively how you figure out how to write to a particular peripheral and that you don't refer to known good code? I'd be frankly amazed to meet someone who does this. While sort of pure in spirit, it would be a vast waste of time for me. Yes, AVR datasheets are good data sheets, but IMHO all data sheets are cryptic at times and nothing helps decoding them better than working examples.

Good is a relative thing and since data sheets in general are so God awful, being best of the bunch is a bit like having a contest for the best contents of a toilet bowl.

Smiley

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
And for you guys claiming to read the data sheet, are you saying that is exclusively how you figure out how to write to a particular peripheral and that you don't refer to known good code?
Yes, guilty as charged.
After more than a decade of AVR usage I've used most peripherals and copy and paste my own "known good code" snippets from earlier projects.
And do a quick check against datasheet to be sure that bit names or register names not differ.
It does not take much time from my life.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

An introductory tutorial on reading AVR Mega and Tiny spec sheets has just been added.

https://www.avrfreaks.net/index.p...

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

And for you guys claiming to read the data sheet, are you saying that is exclusively how you figure out how to write to a particular peripheral and that you don't refer to known good code?

No, absolutely not. But I might be an odd character, but the first thing I did 10 or so years ago (even before the STK500 arrived) was to print out the AT90S8515 data sheet and browse most of it, and then read more thoroughly a few of the chapters.

Likewise when I switched to mainly the ATmega48/88/168 line.

When I got the Luminary (now TI) Stellaris Cortex-M3 stuff it went slightly different: i) The data "sheets" are so extensive that it would take weeks of spare time to read them, ii) OTOH having by then gotten used to reading sheets it was easier to cherry-pick the stuff that one needed first. OTOH I didn't delve so deep into them.

I can readily admit that I've never actually read any section on any analog comparator for any AVR model. Never used thst ,never needed that.

But I still do read a lot of technical stuff, the digital stuff. Going through a data sheet for an analogue device is still a mystery bordering to pure black art..

Are you saying that you haven't thoroughly read through the complete section of, say, Timer/Counter0 for any of your favourite AVRs? :shock:

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It looks there are always a few ways to do the same things, perhaps I will try different ways and see which one work best for me.

In the mean time, thanks all for your inputs and sharing your experiments, that make my learning a lot easier.

And thanks ka7ehk for the tutorial on Mega and Tiny :)

Zhuhua Wu - Electronic Engineering Student

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I guess software (me) and hardware (them) engineers have a different approach. Faced with a new device I determine which peripherals I will use then meticulously read the chapters about those peripherals from end to end and repeatedly until I totally understand everything I'm being told then I attempt to write some software to configure/drive it in the way I want. If I get real stuck I might finally give in and go and hunt on the internet for some code showing me how to do it but I wouldn't start with that because frankly you have no guarantees about the quality of software you find on the internet. For a small scale example just consider how many "libraries" are written for HD44780 support and how many of those are found here to violate documented timing constraints and would therefore only work by good luck or possibly on selected models of electronics(*)

(*) having said that last time I wanted to play HD44780 I did just use some supplied/existing code rather than writing from scratch - so it may not be the best example.

One thing you can (generally) rely on is that if the silicon vendor supplies library/board support/driver code for their CPU peripherals it's usually the case that it's operating correctly and in spec. Same goes for peripheral code supplied with C compilers - they are skilled engineers and wil likely have put a lot of thought into code they supply. Same not necessarily true of Joe Blogs in his bid to become famous on HackADay or Instructables or whatever!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have the datasheets for the chips I am learning ( Atmega 32,16,128) and find them very helpful in showing the SFR information. Relentless and technical. what can we expect. This is a datasheet. For someone who has english as a second language, I can understand it could be a pain. Copying and pasting the needed register info works if you have a second source on the programming side like:
AVR Microcontroller and Embedded Systems: Using Assembly and C (Pearson Custom Electronics Technology) by Muhammad Ali Mazidi, then everything is fine. :)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks Jim, your brief introductory tutorial on reading AVR Mega and Tiny is very helpful.

Thanks

ka7ehk wrote:
An introductory tutorial on reading AVR Mega and Tiny spec sheets has just been added.

https://www.avrfreaks.net/index.p...

Jim

Zhuhua Wu - Electronic Engineering Student