Reading [2:0] in register

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


Anyone can advise what does clko_rate[2:0] mean? Is it trying to denote the 3rd bit of the register?

 

The CLKO frequency is programmed using clko_rate[2:0], CLKO_Ctl Register 0A, Bits 2-0. Table 4-13
lists each setting and its respective frequency.

 

Edinburgh

Last Edited: Wed. Sep 15, 2021 - 08:17 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Total of 16 bits. Which device you use, please.

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

HI   

  I am using AT91SAM9263 EK (host) to interface to NXP MCU as a coprocessor via I2C, and saw this datasheet with [2:0], and wonder what does [2:0] means in a nut shell. 

Edinburgh

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

The notation [2:0] refers to the three lowest bits of that register.

 

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

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

 

 

ka7ehk wrote:
The notation [2:0] refers to the three lowest bits of that register.

Indeed. It is a common notation - not just used by Microchip (or Atmel, before them).

 

In general, [<start>,<end>] refers to a field starting at bit <start>, and ending at bit <end>.

The bit numbers are (usually) zero-based, with zero being the least-significant bit (LSB)

 

So, in the OP example:

 

xtal_trim is an 8-bit field: its bits are numbered 7..0, and it occupies bits 15..8  15..0  of the register;

 

clko_rate is a 3-bit field: its bits are numbered 2..0, and it occupies bits 2..0 of the register.

 

ADDENDUM

 

So the notation is actually used in two subtly different applications:

 

  1. xtal_trim[7,0] and clko_rate[2,0] tell you the sizes of the fields;
     
  2. Register[15,8] and Register[2,0] tell you the locations of the fields within the register
    (and you can also deduce the field sizes)

 

Because clko_rate occupies the bottom (least-significant) three bits of the register, clko_rate[2,0] corresponds to Register[2,0]

 

EDIT

 

Fixed typo - see #6

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Wed. Sep 15, 2021 - 08:27 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:
xtal_trim is an 8-bit field: its bits are numbered 7..0, and it occupies bits 15..0 of the register;
Correction. It occupies bits 15..8 of the register.

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

Oops! - corrected.

 

blush

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...