2024-03-24 01:30 PM - last edited on 2024-09-27 09:42 AM by SofLit
Using a Nucleo-F072RB. I am trying to get the output of CC1 to go low after the CPU does something. Everything is working as expected except I cannot get the line to go low. I have tried both variants of the CC1P bit and neither seems to work. I place a breakpoint at the first line where I touch CCMR1 register and single step. I see that the bits are as I believe they should be but for the life of me I cannot force the output line low (line 3 below --- monitoring with scope). Can someone tell me what I am missing?
__HAL_TIM_DISABLE_IT(&htim15, TIM_DIER_CC1IE);
htim15.Instance->CCMR1 = TIM_OCMODE_TIMING;
htim15.Instance->CCMR1 = TIM_OCMODE_FORCED_INACTIVE;
htim15.Instance->CCMR1 = TIM_OCMODE_TIMING;
htim15.Instance->CCMR1 = TIM_OCMODE_ACTIVE;
Thanks
2024-03-24 02:40 PM
2024-03-24 02:49 PM
Read out and check/post content of TIM and relevant GPIO registers.
JW
2024-03-24 05:42 PM - edited 2024-03-24 05:43 PM
timer registers at said breakpoint in original post and GPIO (PB14 is signal I am monitoring)....this is after a reset and the 1st time hitting the breakpoint
2024-03-25 05:42 AM
This does nothing to change the OC output value.
2024-03-25 06:12 AM
What you set for the xx channel out (in Cube ?) ?
like this:
2024-03-25 06:21 AM - edited 2024-03-25 06:22 AM
I was hoping you were going to decipher the registers, thus find out what's wrong, yourself.
GPIOB_MODER=0x10000000
that means, the field for PB14 is set to 0b01, i.e. GPIO Output, not AF (which would be 0b10).
And AFR for PB14 is set to 0, for TIM15_CH1 it would need to be set to 1 (see Alternate functions table in DS).
In other words, you don't have PB14 set as TIM15_CH1 at all.
But even if you would have PB14 set as AF/TIM15_CH1, as both TIM15_CCER.CC1E = 0 and TIM15_BDTR.MOE = 0, that output would be disabled anyway.
JW
2024-03-25 06:44 AM - edited 2024-03-25 06:46 AM
I would not have posted if I hadn't already looked at those registers (and as you seem to indicate your suggestion would not alter the outcome) ....To me they all looked fine plus the scope is showing me that the I/O is performing to the "toggle on match" as expected. I used CubeMX to initialize things and intentionally I specifically set Channel 1 as "Output Compare No Output" and am using the I/O just as a test to validate something. I am just trying to get the I/O low after it toggles ....
The manual clearly states:
I have tried CCxP both high and low in conjunction with using "FORCE INACTIVE" and "FORCE ACTIVE" but none of the combinations seem to work.
2024-03-25 06:48 AM
> To me they all looked fine plus the scope is showing me that the I/O is performing to the "toggle on match" as expected.
Not with these settings.
You have PB14 set as GPIO Out, and set to 1 in GPIOB_ODR.
JW
2024-03-25 07:27 AM
If I change GPIO->MODER to AF my signal (yellow scope trace) completely disappears. That is not what I want. I am bound to pin PB14 so I cannot change CCR1 in CubeMX to "Output Compare Ch1" which then forces me to use GPIO and generate an Interrupt on match. Here is a scope picture (both micro and macro) showing the issue:
It literally is just a matter of changing the toggle on the I/O to fall low at the end of each toggle. I have attached macro and micro pics showing scope on rising and falling edge of a 4 second sample rate (pink trace).