This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

blinky asm question

hi,

in the blinky asm example for the LM4F120H5QR i found this:

SYSCTL_RCGC2_GPIOA EQU 0x00000001 ; Clock Port A

; activate clock on porta
    LDR R1, =SYSCTL_RCGC2_R                 
    LDR R0, [R1]                                                         
    ORR R0, R0, #SYSCTL_RCGC2_GPIOA    
    STR R0, [R1] 

why is there no metioning of SYSCTL... in the LM4F120H5QR data sheet ?

And why is there a 0x00000001 in SYSCTL.... it starts with a 0x so its a hexadecimal number, but why all the zeroes? looks more like a binary

greetings

 

  • Hello Mitchel,

    In some forums, asking a question like that would result in immediate banishment!  In others, a group of geeks would show up at your door and take you to a place where there are no computers.

    Not here though.  In this forum there is no such thing as a stupid question.  We are here to steer you in the proper direction, otherwise you just might run us over!

    The first thing you should always do if you come across a defined statement or label that you don't know is to search for it in the files of the project.  The SYSCTL as you probable guessed would be for system control.  The RCGC2 would be for Run Mode Clock Gating Control, which you have seen in the data sheet along with GPIO.

    The EQU, assigns a value to this SYSCTRL_RCGC2_GPIO.  If you look at the data sheet page 312, you will notice that the register is divided into two 16 bit section.  You will also notice that GPIOA is R0 and occupies the first bit.  So, the 0x00000001 represent the first bit being enabled out of 8 bits.  

    This nomenclature allows you immediately recognize which bits of the register are enabled.  It is not meant to be referenced as the actual HEX value per se.

    Thanks,

    ...just don't ask another question like that...please!

  • Hi Mitchel,

         Just taking a quick look at the LM4F120H5QR data sheet. 

    1. SYSCTL means System Control and is mentioned at page 224, 5.2.6 of the datasheet.
    2. Why 0x00000001? Its simply because LM4F120H5QR is a 32-bit ARM processor. Registers are written with 32 bit values. 
    -kel
      
  • nobody in his right mind uses 0x00000001 to show that the right most bit of some register is activated. 0x is a hex prefix and this is seriously wrong.

    i know this might be a surprise but in the avr community they use 00000001 to show the same.

    how more obviously could it be?

  • Now after two explanation to your question, I would normally leave it at that but I'm a pedestrian and the occasional cyclist.  So just incase should ever be involved in the automobile industry, I will reply.

    In the header file for the blinky project, the lm4f232h5qd.h, you will notice that every section is preceeded by a comment that says, "The following are defines for the bit fields in the .... register"

    On line 10915 of that header file you will find the define for the bit field of your original question.  If you look carefully you will see a pattern emerge.  Compare this pattern to the same register in the data sheet an it should become apparent to you why this method of bit field designation was chosen.

    This is not an AVR forum so I do not know what compiler you are using, so I can't comment on the method of defining bit fields.

    Perhaps it is a question you should pose to the AVR community, your original question might not seem so surprising there..

    Thanks

  • Mitchel Carter said:
    0x is a hex prefix and this is seriously wrong

    Long time ago, people figured out that 0x would distinguish a hexadecimal value from the other numerical values (decimal, octal, binary, etc . . ), and has been used ever since. This is not AVR community, and how 0x used as a hex prefix might not be as what you expect, and come as a surprise to you. I think if you design your own chip, 0x could be anything you want. 

    - Kel

  • @greenja, thx for your time.

    im sorry that your self esteem is low today, hope you have a better day tomorrow

    @all thx for your time

  • Under most compilers, 00000001 would  be wrong (although in this specific case it would come up with the right value).  This would normally define an octal value in C (because the number starts with 0 but not 0x) number, or in some other languages it would be a decimal number.  The fact that in all cases it would be the same value, the number 1 is just a happy coincidence, but if you wanted to explicitly show the full 32 bit precision, 00000001 would not do it for octal or decimal.

    There is no standard way to represent binary numbers in C source code.  Under gcc extensions you could use the 0b prefix, and the number would be 0b0000000000000000000000000001

    As to assemblers, every assembler has their own syntax for numeric values.  Under some, 00000001 might be a valid 8 bit binary number, but it would only be 8 bits.  I know of few assemblers where hexadecimal doesn't require a prefix or suffix.

    Mitchel Carter said:
    nobody in his right mind uses 0x00000001 to show that the right most bit of some register is activated. 0x is a hex prefix and this is seriously wrong.

    I don't know what world you live in, but in decades of programming in many different languages, and assemblers for many different families of processors, 0x00000001 is most often how I've seen the rightmost bit set in 32 bit numbers.  I've generally not seen binary used much except for 8 bit processors.

  • Mitchel Carter said:
    nobody in his right mind uses 0x00000001 to show that the right most bit of some register is activated.

    Debatable - and tad forceful from one who's been 20 minutes on this forum.

    Yours is pretty much a judgement call - and expecting similarities to the far under-powered AVR may be an unwise objective.

    Rather than resist (really is futile, here) why not "see the light" - that each "0" represents a "nibble" in our 32 bit ARM world.

    Some of the best/brightest here have taken the time to respond to you - attitude adjustment may be far better course...

  • im glad for any information and by now i figured out the part where 8 places represent 4 bits each. maybe im a bit sold on the 8bit per register idea.

    so the syntax 0x is just for the assembler, that makes sense.

  • Mitchel Carter said:
    so the syntax 0x is just for the assembler

    No - we use 0xAB to write a byte to a char; 0xABCD to write to a 16 bit short; and 0x1234ABCD to "seed" a 32 bit value to either a register or an MCU memory location - and each/every of these w/in plain vanilla "C" code.

    You seem to have "seized" upon ASM - that's your choice - but bear in mind that LMI (creators of these M3 Stellaris) were purchased by TI (I believe primarily) due to the great body of work that is StellarisWare - and 99.9% of that is "C."   Of course you can use ASM - but you lose all of the protections and 100's of code "models" which so simplify your life.  Do give StellarisWare a good look - it clearly will help you.  SW-DRL-UGxxxx is the defining document - grouped primarily by MCU peripheral...

    Your attitude way improved - (that's good) - do keep in mind that these ARM MCUs are highly complex - and that ARM has captured every single cell-phone - every one!  Not an Intel (and certainly no AVR) MCU has ever captured a single cell design.  It is this great volume that has enabled these powerful devices to "descend" to we masses - and to potentially achieve very improved performance at fair cost...

  • Mitchel Carter said:
    now i figured out the part where 8 places represent 4 bits each

    Yes,  that is the way Hexadecimal works! Each hex digit represents 4 bits.

    Mitchel Carter said:
    nobody in his right mind uses 0x00000001 to show that the right most bit of some register is activated 

    Quite the contrary!

    As already noted, it is very common practice indeed to explicitly state all the bit values being applied.

    Mitchel Carter said:
     the syntax 0x is just for the assembler

    No. The "0x" prefix notation originates with 'C' - some assemblers adopt the same notation.

    Mitchel Carter said:
     maybe im a bit sold on the 8bit per register idea.

    So, presumably, you never used the 32-bit AVRs, then?

    When we speak of a "32-bit" architecture, it means that 32 bits is the "natural" size for all data that the architecture works with - so one should expect that its registers are likely to be 32 bits wide. Similarly, one would expect that a 16-bit architecture would tend to have registers that are 16 bits wide, etc....

     

  • Mitchel Carter said:

    why is there no metioning of SYSCTL... in the LM4F120H5QR data sheet ?

    No worries! If you open Stellaris® Peripheral Driver Library spmu019o you will find 1242 occurences of SYSCTL ;)

    Now seriously: In Stellaris® LM4F120H5QR Microcontroller DATA SHEET (spms294g) you can find description: Register 119: Run Mode Clock Gating Control Register 2 (RCGC2), offset 0x108

    Mitchel Carter said:

    And why is there a 0x00000001 in SYSCTL.... it starts with a 0x so its a hexadecimal number, but why all the zeroes? looks more like a binary

    It is easier to use hex than binary. For example your 0x00000001 would be 0b00000000000000000000000000000001.

    PS. Why are you using assembly?

    Regards,
    Maciej 

  • MaciejKucia said:
    PS. Why are you using assembly?

    I would guess, coming from 8-bit AVRs, that there's been no pressing need for anything else - so that's the preferred (only?) way the OP knows...?

     

  • Hmm, The OP seems to be confused by hex therefore I assume he is not proficient with assembly. I strongly recommend starting with C as without some level of abstraction introduction to ARM might be challenging.

    Regards,
    Maciej 

  • cb1_mobile said:
    You seem to have "seized" upon ASM - bear in mind that LMI (creators M3 Stellaris) were purchased by TI (I believe primarily) due to the great body of work that is StellarisWare - and 99.9% of that is "C." 

    Youse guys tad late to this "Use C" party...   Suspect that some mention of "StellarisWare" would strengthen such repetition...