cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103 Assembler

darkfirefighter
Associate III
Posted on August 25, 2010 at 09:21

STM32F103 Assembler

7 REPLIES 7
Posted on May 17, 2011 at 14:04

Not sure there is an ''assembler'' manual from ST, the STM32 uses the ARM Cortex M3 with a Thumb2 instruction set. Joseph Yiu's book would represent a good starting point, if the PDF/HTTP manuals from ARM don't suffice.

http://www.amazon.com/Definitive-Guide-ARM-Cortex-M3-Second/dp/185617963X/ref=sr_1_1?ie=UTF8&s=books&qid=1282751866&sr=8-1

The RM0008 STM32 Reference Manual would be a good starting point for register info including the timers. 13902.PDF as I recall.

Peripheral registers access just like any other memory location on an ARM part. You will need to load the value into an ARM CPU register, and then mask/shift the bit(s) you want and do branches, comparisons, etc.

Assembler doesn't provide the abstractions found in high level languages, you have to implement things in a more basic fashion.

  ldr r2, =0x40000400 ; TIM3

  ldr.w r0, [r2, #16] ; TIMx_SR

  ands r0,#0x01 ; Mask Bit 0 (UIF)

  beq _uifclear

  bne _ufiset

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
stforum2
Associate II
Posted on May 17, 2011 at 14:04

ARMv7-M Architecture Application Level Reference Manual (ARM DDI 0405B)

describes the instruction set

Posted on May 17, 2011 at 14:04

I'll note that you can also do ''bit-banding'' access to peripheral registers, which might help for a single bit, less helpful for bits.

    ldr    r4, =0x42420000 ; BB 40021000.0 RCC Base

    movs    r1, #1

    str    r1, [r4, #96]   ; 42420060 BB -> 40021000.24=1 PLLON

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
stforum2
Associate II
Posted on May 17, 2011 at 14:04

''I also have an other question is it possible to access the bits of an register directly?''

Yes, you can do that using bit banding.

darkfirefighter
Associate III
Posted on May 17, 2011 at 14:04

Hi,

Thanks for your help 🙂

So I think bitbanding is the right for me, because i only want to change one bit.

With the bitbanding only one bit is affected or? So all other bits in the register keep their status?

And where do i find the adresses of the pheripherials? I searched in the programming manual and in the RM0008 but i havent found them.

regards

stforum2
Associate II
Posted on May 17, 2011 at 14:04

You will find the memory map for the peripherals in the data sheet for the chip that you are using. From this you can get the base address for the registers of a particular peripheral.

You will find the offsets of each register from base address in RM0008.

Or they will be defined in header files provided with your development tools.

darkfirefighter
Associate III
Posted on May 17, 2011 at 14:04

Thanks, i found it 🙂