-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Access to COMP_CSR using MMIO16 writes same data to both half of the 32 bit register on STM32F0 #1289
Comments
so.. first off, does it happen with an older gcc? 10.2 is the brand new one right? |
FTR, I don't see anything wrong in above assembler code (it reads halfword at |
The reference manual would normally make explicit mention if it wasn't allowed, fwiw. |
I can see the same problem with GCC 11.2: COMP_CSR1 = COMP_CSR_EN | COMP_CSR_OUTSEL_TIM2_IC4;
But when done via MMIO32, all goes as expected:
Since there is the above issue in regards to the current "split" API, I would personally vote for following the reference and having a single There is also a typo in |
There's a note in RM0091, section "System and memory overview" that says,
So I'd say that's what's happening, and we just need to drop the MMIO16. I'm not sure whether that's an M0/M0+ issue, or not, because I don't recall that being an issue on some other targets, either way we'll need to drop it. |
Fixes: libopencm3#1289 While it had seemed a clever trick to access COMP_CSR as two 16bit registers, apparently in the real world, this didn't behave as expected. Switch the register definitions to 32bit and adjust all the functions to auto select the correct portion of the register. NEEDSTEST: this has been coded only, I personally have no code using this, but it seems like the correct approach, and the current code is obviously broken. Signed-off-by: Karl Palsson <karlp@tweak.au>
I've worked up some changes that should fix this, but I don't have any test code for this, or test hardware. IF either of you could try this out and let me know, I can merge it. |
I've noticed a strange bug in the comparator library for STM32F0, the COMP_CSR register (one 32 bit register common for comparator 1 and 2) is accessed in the library using the following approach
#define COMP_CSR(i) MMIO16(SYSCFG_COMP_BASE + 0x1c + (i)*2)
Whenever I try to write to a half of the register, the data are written to both halves. E.g. the CSR register is empty, after executing
COMP_CSR1 |= COMP_CSR_SPEED_MED
it contains 0x40004 instead of just 0x4.The dissasembled code is:
I'm using gcc version 10.2.0.
The text was updated successfully, but these errors were encountered: