/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / Bit Band Alias

Username:     
Password:     
             

Forum

# 1   2011-03-14 01:16:25 Bit Band Alias

primagen
Member
Registered: 2010-12-07
Posts: 13

Bit Band Alias

Is it possible to make bit operation with alias?
For Toggle led i use this:
void led_toggle(GPIO_TypeDef* GPIOx, uint32_t GPIO_BSRR_BSx )
{
GPIOx->ODR ^= GPIO_BSRR_BSx;
}

but how it works with:
#define PB6 (*((volatile unsigned long *) 0x42218198 ))
PB6^=1; doesnt work

Offline

 

# 2   2011-03-14 08:05:05 Bit Band Alias

yrt
Administrator
From: Grenoble-France
Registered: 2008-06-11
Posts: 520
Website

Re: Bit Band Alias

I did not get the same result for the alias address.

The formula is :
bit_word_addr = bit_band_base + (byte_offset x 32) + (bit_number × 4)

In your case :
bit_band_base =  0x4200 0000
byte_offset = 0x10C10 (GPIOB = 0x4001 0C00, GPIOx_BSRR = 0x10)
bit_number = 0x06

So, the result is 0x420218218 !?!

Take a look at some examples in this topic : 
http://www.stm32circle.com/forum/viewtopic.php?id=1080

Offline

 

# 3   2011-03-14 22:44:05 Bit Band Alias

primagen
Member
Registered: 2010-12-07
Posts: 13

Re: Bit Band Alias

Hi,

I think you make an mistake for "byte offset".

Its 10C0C.
The problem is not the use of PB6=1 or PB6=0
I want to make bit operations on these defines like above

Offline

 

# 4   2011-03-15 07:24:31 Bit Band Alias

yrt
Administrator
From: Grenoble-France
Registered: 2008-06-11
Posts: 520
Website

Re: Bit Band Alias

Ok,

The address is 10C0C for ODR register, 10C10 for BSRR
It seems that it was working for "sentinel" as indicated in the post before.

Offline

 

# 5   2011-03-15 15:00:01 Bit Band Alias

primagen
Member
Registered: 2010-12-07
Posts: 13

Re: Bit Band Alias

working for sentinel ?? What does this mean....
To my problem:
Am i able to use bit operation if i make pointer to BSRR alias??

Offline

 

# 6   2011-03-16 07:05:03 Bit Band Alias

yrt
Administrator
From: Grenoble-France
Registered: 2008-06-11
Posts: 520
Website

Re: Bit Band Alias

I was just talking about the guy who posted these informations :http://www.stm32circle.com/forum/viewtopic.php?id=1080 !
I think it should be working with BSSR or ODR.

Offline

 

Board footer