Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to name bits in register

Alan8947

Full Member level 4
Joined
Sep 21, 2016
Messages
215
Helped
9
Reputation
18
Reaction score
11
Trophy points
1,298
Activity points
3,746
Hi
I am not familiar with the way to read the bit number of the register. This is what I have:

Register bit.jpg


You see in the text description it said (CS12:0), how does that relate to bit(2..0) in the TCCR1B register.

I am just trying to learn the meaning of (CS12:0) . How does this mean (CS12..CS10)? I am just not familiar with the way it's written.

Thanks
 
It seems they mean cs1(0), cs1(1), cs1(2) i.e. three bits for clock select.
The addition of 1 to cs is to confuse people.
 
It seems they mean cs1(0), cs1(1), cs1(2) i.e. three bits for clock select.
The addition of 1 to cs is to confuse people.
Thanks

I just never get used to the new stuff, I much prefer(CS12..CS10). I pretty much guessed this much, I just want to confirm with someone.

So
Register bit 2.jpg


bit(4..3) is called (WGM13:2)? Just to confirm.

Thanks
 
Last edited:
You just need to identify each bit meaning as per register index:
reg bit 2:0 if for CS1(with cs1 having bits 2:0)
reg bit 3 is for WGM12 (which is one bit only)
reg bit 4 is for WGM13 (one bit only)
reg bit 5 is unused
reg bit 6 is ICES1 (one bit)
reg bit 7 is ICNC1 (one bit)
 
You just need to identify each bit meaning as per register index:
reg bit 2:0 if for CS1(with cs1 having bits 2:0)
reg bit 3 is for WGM12 (which is one bit only)
reg bit 4 is for WGM13 (one bit only)
reg bit 5 is unused
reg bit 6 is ICES1 (one bit)
reg bit 7 is ICNC1 (one bit)
Yes, that is understandable, I just want to confirm (WGM13:2) is bit(4..3)
thanks
 
The top set is register index (0 to 7)
The boxed area is the names they are giving each bit (to cause confusion)
The lowest set is the initial values.

so based on that WGM12 & WGM13 exists but I don't think they will refer to WGM13:2
 
Then I am confused. I further see another example.
Register bit 3.jpg

register bit 4.jpg

Register bit 5.jpg


In this case, (WGM13:0) spanks 2 different registers as show. (WGM13:0) is actually bit(1..0) of TCCR1A and bit(4..3) of TCCR1B

Is this correct? You see how confusing it is?

Thanks
 
Yes that is what they mean; WGM1 is spread across and they want to refer to all four bits now their way. It is very bad scheme of indexing and naming.
 
Hi,

WGM13 is a precise (still not very intuitive) name for the bit.
"WGM" = Waveform Generation Mode
"1" = timer/counter module "1"
"3" = bit 3 (for the waveform generation mode)

Problem is that the timer/counters are numbered: timer1, timer2, timer3..

***
One could name them: TimerA, TimerB, TimerC
Then the name would be WGMB2, WGMB1, WGMB0
all together: WGMB2:0
Where WGMB describes the (combination of) waveform genertion bits of timerB
and 2:0 desrcibes the single bits

***
So for the upper case you should read them as [WGM1]2, [WGM1]1, [WGM1]0
or all together [WGM1]2:0
Dismiss the brackes and you get the same as in the datasheet.

***
Not very nice, but still valid.

*****
Now you may complain about WGM1(1:0) to be in a different register than WGM1(3:2).
I´m pretty sure this is not to confuse people, it´s done because the AVRs developed. An AVR is not designed as a one shot from scratch.
Development means it is a continous (at least over a longer period) taking process.
Many development stages needed to be processed, many sibilings were developed.
During this process one needs to do some handstands. No one wants to do this, but sometimes there is no good alternative.
And if you chose an alternative way ... another person will complain. You can't please everyone.

Klaus
 
Last edited:
Thanks both of you.

I just want to confirm as this is important and is new to me. Like I said, the last time I involved in detail assembly type programming was 1982. So far, the content is not hard, just more. My major issue is to understand the new way of things. 3 different buses in one chip was new to me and that really held me up for a while. But since, it's been smooth. I gone through about 140pages of the ATmega328 datasheet. That's about 1/2. Hopefully I can get through it in a month( I barely put in 1hr max max a day, slow) for old time sake, then I can go to the new C++ style and play with the kit.

Thanks
 
Spreading bits over multiple register is a common practice with old 8-Bit processors like AVR series.

The only confusing point in the datasheet is a syntax like CS12:0 which would be commonly read as 13-Bit register. As KlausST explained, you should place brackets or similar to clarify that it actually means CS1_2:0, register CS1 containing 3 Bits.
 
Thanks, I am not worry about how I write it, I just want to make sure I understand when reading the datasheet.

Thanks
 
That's one thing about a product that is old but keep having upgrades. They really need to spend more time on fixing the datasheet. I bet the older version has less counters and they add more in the later version.

I went back and look at the datasheet both the 8bit and 16 counters, It never said clearly HOW MANY COUNTERS TOTAL. I google, right away it said 3. counter 0 and 2 are 8bits, 1 is 16bits. Datasheet only talk about counter 0 for 8 bits.

Don't they want to attract people that NEVER work on AVR? Not just people been using for years and know the history? This is the first time I study this, The datasheet is LOUSY. People just cannot say "you have to understand the history".

I really try to ask less question as possible particularly simple and stupid ones. I tries looking up youtube videos. There are plenty, problem is I cannot understand their English. They speak with such heavy accent I just cannot understand them. I yet to find any video that is useful with native English speakers. English is my second language, maybe if I am better in English, I'd be able to understand them.
 
I went back and look at the datasheet both the 8bit and 16 counters, It never said clearly HOW MANY COUNTERS TOTAL. I google, right away it said 3. counter 0 and 2 are 8bits, 1 is 16bits. Datasheet only talk about counter 0 for 8 bits.
Come on!
Don't complain. Just read the feature list on the first page!
It says:
● Two 8-bit Timer/Counters with separate prescaler and compare mode
● One 16-bit Timer/Counter with separate prescaler, compare mode, and capture

Or go through the "Table of contents" at the end of the datasheet.
There is:
* 8 bit Timer/Counter0
* 16 bit Timer/Counter1
* 8 bit Timer/Counter2
...how many timers are they..and how many bits do they have?

Or go through an AVR comparison table..

Need more sources?

Hint: besides using these overviews .... every PDF viewer comes with a search function. Use it!

Klaus
 
Last edited:
I can see that you're trying to study the timer of an Atmega microcontroller. I can also see that you've received many helpful and right answers. By the way, to make your understanding better, it's always best to do some projects. The most common application of timers is to make clocks. You can make and program a clock like this by configuring the timers of an AVR microcontroller:

 

LaTeX Commands Quick-Menu:

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top