Using a Memory Copy block to read/write a single bit gives an error, and workaround not working?
5 ビュー (過去 30 日間)
古いコメントを表示
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.
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
1 件のコメント
Walter Roberson
2023 年 10 月 17 日
From what I have seen, these days very few devices have hardware bit-addressing -- and the few that do only seem to have it for a small range of addresses (that is, they might have special peripheral I/O commands that allow setting individual bits for I/O registers... but not for general memory)
The TMS320C28x does not appear to have any bit-addressing capabilities
回答 (1 件)
Antonin
2023 年 10 月 17 日
編集済み: Antonin
2023 年 10 月 17 日
Hi Mike,
A workaround is to use the .all notation to have access to the whole register, you can then use bit manipulations to access the bit you want. Getting the address of .all will work
So in the Memory Copy block to access EPwm2Regs.TBCTL.bit.PHSDIR use the source code symbol with &EPwm2Regs.TBCTL.all and use a mask and shift to access the bit you want. The same trick applies for both read and write operations.
I hope it helps,
Antonin.
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!