Just my 2 cents ...
Using bit fields is defenitely not the best way to do bitwise I/O on the
lpc21xx
The LED2 = 1 instruction will not be an atomic instruction when done
using bit fields.
Use:
#define LED2 (1<<12)
port0_set = LED2
makes use of the special I/O set register. This is faster (it saves a
read from port0_reg) and atomic
Bit fields will do the job. But if - in the end - you discover that you
need to optimize your code this will cost you some time ...
Rob
Joel Winarske wrote:
>>I was looking for something that would let me do:
>>
>>if(LED1)
>> LED2 = 1;
>>
>>This would require associating LED1 and LED2 with a particular bit in
>>the appropriate IOPIN register. Judging from your response, this is
>>not possible with GCC and ARM?
>>
>>
>
>If you're ok with bit fields, try this (it works in IAR, should work in
>GCC):
>
>struct PORT {
> unsigned bit0:1;
>
>
...Message
Re: [lpc2000] Re: Bit set/clear w/ gcc
2006-01-12 by Rob Jansen
Attachments
- No local attachments were found for this message.