Using a Memory Copy block to read/write a single bit gives an error, and workaround not working?

3 views (last 30 days)
Hi, I am trying to read data from and write data to an ePWM register. I can read the whole register, but when I try to read half (EPwm2Regs.TBPHS.half.TBPHS) or just a single bit (e.g., EPwm2Regs.TBCTL.bit.PHSDIR), I get a compiling error:
error: taking the address of a bit field is not allowed
As a workaround, I can read a whole register (EPwm2Regs.TBCTL), and then extract a single bit (PHSDIR = bit 13).
However, if I try to write to a single bit or half, I also get the same error.
I tried to use a similar approach: reading the whole register, changing a particular bit and then writing a new value to the same register, but this does not work.
1) Do I need to do anything else to enable writing using the Memory Copy block?
2) Is it possible to write to only one bit or half register? In Texas Instruments help files this seems to work
My setup for writing a phase offset looks like this
Memory copy destination (&EPwm2Regs.TBPHS)
Application
I am trying to write to the upper part of the TBPHS register a new value, but it seems the memory copy block cannot overwrite the existing value. I used a similar approach to write to a single bit, but it didn't work either.
ePWM2 block settings

Answers (0)

Products


Release

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by