Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[moved] ARM some registers are only word accessible...

Status
Not open for further replies.

cyberjok

Member level 1
Joined
Dec 2, 2006
Messages
32
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,496
ARM some registers are only word accessible...


Code C - [expand]
1
2
3
4
5
6
struct {
unsigned x1: 3;
unsigned x2: 13;
} x @ 0x0x40090120;  //0x40090120 ONLY WORD ACCESSIABLE
 
x.x2 = 2;                     // NOW ARM will enter hard fault handler;



so any idea to make compiler(IAR) access 0x0x40090120 ONLY base on word type?

- - - Updated - - -


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
typedef struct {
 unsigned x1: 3;
 unsigned x2: 13;
 } x_t;
 
x_t x_temp;
 
x_temp = (x_t *)0x0x40090120;
 
x_temp.x2 = 2;


(unsigned int *)0x0x40090120 = (unsigned int *)(&x_temp);

-----

- - - Updated - - -

a solved idea as follow shows; but it is not simple...

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
typedef struct {
 unsigned x1: 3;
 unsigned x2: 13;
 } x_t;
 
 x_t x_temp;
 
(unsigned int *)(&x_temp) = (unsigned int *)0x0x40090120 ;
 
 x_temp.x2 = 2;
 
 (unsigned int *)0x0x40090120 = (unsigned int *)(&x_temp);

 
Last edited by a moderator:

Actually and unfortunately your code is not doing what you think:

I. 0x0x40090120 will not compile at all.

1. This structure is 4 bytes long (not 16)
2. (unsigned int *)(&x_temp) = (unsigned int *)0x0x40090120 ; -will bot compile at all
2.1 (unsigned int *)0x20000120 = (unsigned int *)(&x_temp); will not compile at all.

those two will compile but both of them do not do what you expect as the structure is 4 bytes long.
*((unsigned int *)0x20000120) = (unsigned int)&x_temp;
*((unsigned int *)0x20000120) = *((unsigned int *)&x_temp);

3. 32 bit access requires alignment. You cam always do two 16 bit operations instead.
3. Line 12 reads and writes 32 bit value (not 16)4
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top