cancel
Showing results for 
Search instead for 
Did you mean: 

Testing timer and unable to get the expected output

SWenn.1
Senior III
htim3.Init.Prescaler = 20 - 1;
  htim3.Init.CounterMode = TIM_COUNTERMODE_UP;
  htim3.Init.Period = 200 - 1;
  sConfigOC.OCMode = TIM_OCMODE_TOGGLE;
  sConfigOC.Pulse = 0;

I am using a NUCLEO-L476 and have a 20MHz clock source. I am using no interrupts and PA6 as the pin to monitor the output....This is all configured in CubeMX...

from above I would expect counter clock = 1MHz, a UIF is generated every 200us (although I have no callback here), but I do not see PA6 toggling....

any help would be great as these parts are a pain to use...

The call I am using is

HAL_TIM_Base_Start(&htim3);

The debugger shows the ARR and PSC correct, the CEN is set and the counter is counting....PA6 was configured as AF2 as expected....and yes my scope is on the correct pin.....

4 REPLIES 4

> sConfigOC.Pulse = 0;

Doesn't this mean zero length pulse (i.e. none)? I don't know, I don't use Cube.

JW​

SWenn.1
Senior III

I am not sure...My head is in a fog trying to figure all the settings out and the naming convention of stuff is beyond poor....The pulse if you dig deep enough is the value loaded into the CCR register when the output is set to compare so I am pretty sure leaving it at 0 is ok when output is frozen?!?!.....I find it very difficult to get the compare outputs to work the way I think they should after reading documents....The UID is consistent however. Interesting tid bit....It you use the

HAL_TIM_OC_Start_IT function the HAL library doesn't show any callback functions for it?? Looks like you just place your code directly in the timer ISR.....

so frustrating the inconsistencies.....

I envy you for not using Cube ....I long for the day of bare metal programming but for now Cube at least gets me part way there with the setup....

S.Ma
Principal

Did you enable the compare channel? It is needed separetely frok enabling timer.

> I long for the day of bare metal programming but for now Cube at least gets me part way there with the setup....

That's not "a" day. The only way to get there is through learning, and that takes time. You have to unlearn Cube and then you are at point zero. I'm not kidding, you're worse off than if you'd never seen Cube, and every day you are using Cube you're getting further away. That's the price you've agreed to at the day you've chosen the easy path.

Cube, and for that matter any other "library", is a great way to do quickly the one thing which its authors envisaged, but going down any other of the innumberable roads is then much harder than without it.

At any case, the mcu works out of registers not out of any source code, so read out and check/post content of TIM and relevant GPIO registers.

JW