About operator |=

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

About operator |=

208 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by hilite on Wed Nov 09 08:14:17 MST 2011
It is a question about ARM Cortex-M3 (LPC1434) of NXP.
For example, in order to start AD converter, the 24th bit of register AD0CR is set, but it is a code.
LPC_ADC->CR |= (1<<24);
It is writing.
Operator "|=" currently used in code When operation of is "READ MODIFY WRITE", there is a vague feeling of anxiety.
It has written on the manual that the 28..31 bits of this register (AD0CR) is a reservation bit, and saying must not set 1.
And it is written that a value is not defined when the 28..31 bits is read .
That is,if operation of is "READ MODIFY WRITE", "1" may be written in 28..31 bits.
Is this my mistake?
Thanks.
(I'm japanese.It is pardon with strange English.):)
0 Kudos
1 Reply

194 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Wed Nov 09 08:36:06 MST 2011

Quote: hilite
Is this my mistake?



No

You could read, reset, modify and write instead:
LPC_ADC->CR = (LPC_ADC->CR & ~(0x0F<<28))|(1<<24);
0 Kudos