Bit banding

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Bit banding

2,246件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by JohnR on Thu Aug 26 06:13:51 MST 2010
Hi,

I am trying to get bit banding working following an example from Keil using the free version of the LPCExpresso environment.

Neither the writes to, or the reads from, the bitband region seem to work. The region is defined as:

[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]#define[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] RAM_BASE 0x20000000[/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]#define[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] RAM_BB_BASE 0x22000000[/LEFT]
[/SIZE]
Do I need the full version of the compiler or is there some compiler switch that I have not turned on?

John.
0 件の賞賛
返信
11 返答(返信)

2,203件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by gogamoga on Tue May 08 03:43:27 MST 2012

Quote: JohnR

...The structure above does only take up 1 byte



And 3 instructions per each assignment: load, logic, store - which in no way are atomic
0 件の賞賛
返信

2,203件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by JohnR on Thu Nov 18 18:11:55 MST 2010
I stumbled on a post today that described bit fields - I should have known about this before as it is a standard C language feature.

Thus for instance


[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][B]struct [/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000]greek {[/COLOR][/SIZE][LEFT]
[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]char  [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]alpha[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][B]:1;[/B][/SIZE]
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]char  [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]beta[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][B]:1;[/B][/SIZE]
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]char  [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]gamma[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][B]:1;[/B][/SIZE]
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]char  [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]delta[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][B]:1;[/B][/SIZE]
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]char  [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]epsilon[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][B]:1;[/B][/SIZE]
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]char  [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]zeta[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][B]:1;[/B][/SIZE]
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]char  [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]eta[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][B]:1;[/B][/SIZE]
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]char  [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]theta[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][B]:1;[/B][/SIZE][/LEFT]
[SIZE=2][B]};[/B][/SIZE]
[/COLOR][/SIZE][/COLOR][/SIZE]
[LEFT][SIZE=2] [/SIZE][/LEFT]
[SIZE=2]//--------------------------------------------------------//[/SIZE]

[SIZE=2][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]struct[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] greek test;[/SIZE]

[/COLOR][/SIZE][/COLOR][/SIZE]

[LEFT][SIZE=2]test.[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]alpha[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = 0;[/SIZE]
[SIZE=2]test.[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]zeta[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = 1;[/SIZE][/LEFT]

[LEFT]The structure above does only take up 1 byte.[/LEFT]

[LEFT]JohnR.[/LEFT]


[/SIZE]
[/LEFT]
0 件の賞賛
返信

2,203件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by JohnR on Sat Oct 30 05:29:52 MST 2010

Quote:
The UART has this 8-bit scratch register



Thanks - I would never have thought of looking there. I wonder whether UART routines do usually use this register. Not that I need a UART in my present system.

John.
0 件の賞賛
返信

2,203件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Chucky on Fri Oct 29 11:18:21 MST 2010
I just had the same problem, but you can use bit-banding on the peripheral area of the LPC1343.

The UART has this 8-bit scratch register, so you can use that for having 8 flags that you can set or clear a bit faster than conventionally, using the bit-banding technique.

Hope it helps,

Chucky :)
0 件の賞賛
返信

2,203件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by JohnR on Thu Aug 26 09:55:34 MST 2010
Thanks for the reply, even though the answer is really disappointing.

I was hoping to use the bitbanding feature not so much as it was faster (only by one instruction) but it was supposed to be an atomic instruction.

I hope that there are no more similar gotchas that are not documented for this family.
0 件の賞賛
返信

2,203件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Thu Aug 26 09:37:32 MST 2010
NXP have confirmed to me that there is no bitbanded memory on LPC13xx. I have asked them to update the User Manual to avoid any confusion.
0 件の賞賛
返信

2,203件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Thu Aug 26 08:46:39 MST 2010
I have asked NXP to clarify, but it looks like LPC13xx doesn't have any memory that can be bitbanded.
0 件の賞賛
返信

2,203件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by JohnR on Thu Aug 26 08:25:21 MST 2010
"LPC13xx does not have memory at 0x20000000"

Yes that's what I don't understand about bit-banding.

The user manual for LP1343 shows 0x20000000 as reserved, but 0x22000000 as SRAM bit-band addressing.

So I am now totally confused.

John.

[FONT=Arial][SIZE=1][FONT=Arial][SIZE=1]
[/SIZE][/FONT][/SIZE][/FONT]
0 件の賞賛
返信

2,203件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by igorsk on Thu Aug 26 08:11:53 MST 2010
LPC13xx does not have memory at 0x20000000.
0 件の賞賛
返信

2,203件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by JohnR on Thu Aug 26 07:42:23 MST 2010
Hi

Here is the code

[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]#ifdef[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] __USE_CMSIS[/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]#include[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"LPC13xx.h"[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]#endif[/LEFT]
[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT]
 [/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]#define[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] BITBAND_SRAM_REF 0x20000000[/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]#define[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] BITBAND_SRAM_BASE 0x22000000[/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]#define[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] BITBAND_SRAM(a,b) ((BITBAND_SRAM_BASE + (a-BITBAND_SRAM_REF)*32 + (b*4))) [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// Convert SRAM address[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT][/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]#define[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] MAILBOX 0x20004000[/LEFT]
[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f][LEFT]// Mailbox bit 0[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]#define[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] MBX_B0 *(([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]volatile[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]unsigned[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] *)(BITBAND_SRAM(MAILBOX,0)))[/LEFT]
[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f][LEFT]// Mailbox bit 7[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]#define[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] MBX_B7 *(([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]volatile[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]unsigned[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] *)(BITBAND_SRAM(MAILBOX,7)))

 
 
 [/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]int[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [B]main[/B]([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]) {

[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]unsigned[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] temp = 0;
MBX_B0 = 0; [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// Word write[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT]temp = MBX_B0; [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// Word read[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT]MBX_B0 = 1; [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// Word write[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT]temp = MBX_B0; [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// Word read[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT]MBX_B7 = 5;
temp = MBX_B7; [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// Word read[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]return[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 0 ;
}

John.[/LEFT]
[/SIZE]
0 件の賞賛
返信

2,203件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Thu Aug 26 07:12:02 MST 2010
There are no special compiler switches required for bitbanding - it works through memory accesses.

If you post your example, we'll let you know where you have gone wrong
0 件の賞賛
返信