Hi
Does anyone know of a way to set the EICRA Regsiter to 11 in one step using only library calls?
I know how to do it in C but strictly using the Arduino calls does anyone know of a way to set the Least sig bits on the EICRA to both high is the question?
I cant think of a way. It has to be down in one clock cycle to prevent possible interrupts from interfering during the set.
Thanks
automagp68:
It has to be down in one clock cycle to prevent possible interrupts from interfering during the set.
Impossible. All references are read-modify-write.
Just protect the calls to attachInterrupt and detachInterrupt. Or modify the core. You have the source code for both.
Thanks
this is more of a conceptual homework question so thats why i was getting a second opinion.
I pretty much figured there was not a way to do it.
But i could just simply shut interrupts off do the set and then turn them back on. Is that what you mean?
Thats the only way i can think of to protect it
automagp68:
But i could just simply shut interrupts off do the set and then turn them back on. Is that what you mean?
Yes. Wrapping all calls to attachInterrupt and detachInterrupt may work but it is not the actual goal. The goal is to protect all shared resources (the hardware like the EICRA and any global / static data).
Were I in your shoes I would modify the core. That code is much closer to the goal. It will be much easier to tell if you have protected what needs to be protected.