I don't think that's correct. Bit 25 *will* be cleared, but the |= won't
help. The 'SET' registers will only set the GPIO bits. I think they are
always read back as '0', or at least they revert to '0' as soon as they have
modified the output latch. Read the user manual for read values on GPIO SET
and CLR registers.

The PIN register, after your pair of operations, will have bits 25 and 18
(and their corresponding output latches) set; The IOxSET registers, I'm
fairly sure, are read as '0'. I would not expect a read modify write
instruction such as |= to get the value of the first operation every time.

Another way to do this in just one operation:

IO0SET = ( (1 << 25) |  (1 << 18) );

On Tue, Oct 25, 2011 at 8:17 AM, Andrew Greenberg <and...@psas.pdx.edu>wrote:

> > I have a question about the GPIO registers. Let's say I do the
> > following assignment:
> >
> > IO0SET = 1 << 25; IO0SET = 1 << 18;
> >
> > Will the bit in position 25 will be set or cleared ?
>
> Cleared. On the first line, you're writing in (1 << 25) which is
> 33554432 (in decimal). On the second line, you're writing the IO0SET
> register with the value 262144. Doesn't matter what was in it before,
> it's now whatever you set it to.
>
> If you *want* to have it still have the same bits, you'll have to use an
> OR operation:
>
> IO0SET |= (1 << 18);
>
> in which case, assuming that what you really meant for line 2, the value
> in the register is now 33816576.
>
> Andrew
>
> --
> -------------------------------------------------------
> Andrew Greenberg
>
> Portland State Aerospace Society (http://psas.pdx.edu/)
> and...@psas.pdx.edu  C: 503.708.7711
> -------------------------------------------------------
>
> _______________________________________________
> psas-avionics mailing list
> psas-avionics@lists.psas.pdx.edu
> http://lists.psas.pdx.edu/mailman/listinfo/psas-avionics
>
_______________________________________________
psas-avionics mailing list
psas-avionics@lists.psas.pdx.edu
http://lists.psas.pdx.edu/mailman/listinfo/psas-avionics

Reply via email to