This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Compilation fault using Keil uVision

Hello all!

I'm writing to a chip with a cortex m-4  in it and the compiler creates a weird assembly:

I'm trying to develop an I2C driver so i have a made some unions to allow easy access to registers, it all worked fine until today - today things got quite phishy!

take a look:

compiler option:

here is the code for the union of "reg":

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
typedef union
{
uint32_t value;
struct
{
unsigned dummy1 :1
unsigned dummy2 :1
.
.
.
unsigned dummy32 :1
}fields;
} IC_INTR_MASK;
/******************************/
//module typedef
typedef struct _MODULE_S
{
IC_INTR_STAT IC_INTR_STAT;
} I2CInitDef;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

As you can see the compiler creates the assembly with a "!"(write back to the register) - so after I write 0x00 to "reg->IC_INTR_MASK.value" the pointer of "reg" is no longer point to the right address!

I can tell I'm using this method to write hardware registers all over my code and it always works fine! what do you thing might be the problem here?

0