Leonardo Santos wrote:
>Hello All:
> I'm working with a LPC2106 using the GCC 3.4.4 toolchain (GCC + binutils 2.15
>+ newlib 1.13). I wrote a union and a structure to access the P0 pins
>individually, like this:
>
>typedef struct {
> int p0 : 1;
> int p1 : 1;
> int p2 : 1;
>(...)
> int p30 : 1;
> int p31 : 1;
>}port_t;
>
>typedef union {
> port_t pins;
> unsigned int reg;
>} ioreg;
>
>typedef struct {
> ioreg iopin;
> ioreg ioset;
> ioreg iodir;
> ioreg ioclr;
>}gpio_t;
>
>So I declare a pinter like
>
> volatile gpio_t *gpio = 0xE0028000;
>
>If I access the registers using
>
> if( gpio->iopin.reg & 0x01 )
>
>or
>
> gpio->ioset.reg |= 0x00008000;
>
>Everithing works fine! But if I try a code like this:
>
> gpio->ioset.pins.p15 = 1;
>
>To set P0.15, P0.23 and P0.31 are set too!
>
Seems as if the bit field is a short int...
>I had tried this code in my Linux
>workstaion and it works just fine. The compiles setting I'm using are
>
>arm-elf-gcc -c -Wall -D GCC_ARM7 -mcpu=arm7tdmi -Tlpc2106-rom.ld -Wcast-align
>-O3
>
>So I'm compiling it in ARM mode. Any clues? Is this a compiler issue ( I'm not
>using the right parameters)?
>
>Thanks a lot!
>
>
>
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.7.3 - Release Date: 15/03/2005Message
Re: [lpc2000] C union not working
2005-03-17 by Micron Engineering
Attachments
- No local attachments were found for this message.