Posted by "Bal...@foo.is [lpc2000]"●August 25, 2015
I have a project that uses LPC2387 and makes extensive use of the timer match
A problem I have is that the timer match control is stored in the same register
as the status of the bits.
This is the TxEMR register.
Bits 3 through 0 contain the states of the output pins, readable and
Bits 11 through 4 contain the control bits that tell the comparators what to do
on a match.
Problem with this design is that making alterations to the control bits is
liable to conflict with
changes that happen on the state bits, done by the comparators.
Effectively, with instructions like this:
- ldr into register address of T3EMR
- bic or orr to change the states of the control bits
- str from register back to T3EMR
You're going to have a problem if the comparator matches during the non-atomic
operation where a copy is made of the EMR
and that copy stored back on the EMR overriding the change that the comparator
I think it's extremely silly to store state and control bits on the same
register, where the state bits are writable and can be overwritten by attempts
to alter the control bits.
Now, I have a question, is there a way to atomically change the bits on those
registers without making a copy first?
Is there a way to lock access to the register while the change is being made?