cancel
Showing results for 
Search instead for 
Did you mean: 

[Solved] STM32F4-Discovery: trouble with example TIM_OCTOggle

t2399
Associate II
Posted on June 30, 2015 at 10:23

 Hi.

I'm trying to run TIM_OCToggle example from SPL 1.4.0.  It works in general, but I think it isn't correct: all frequencies are equals. I checked it by oscilloscope. Waveforms are the same and shifted each other. As described in readme.txt, different pins should generates different frequencies.

 What wrong? I want get two signals with different frequencies 1:32 | 1:16 | 1:8 .

http://pastebin.com/3SnUyz7A

and

http://pastebin.com/cR6yWFgY

#stm32f4 #discovery #!stm32f4-disco #timers
2 REPLIES 2
t2399
Associate II
Posted on June 30, 2015 at 11:56

 Hm.. Reference manual RM0090 in the section 18.4.7 says:

Bit 3 OC1PE: Output compare 1 preload enable

...

Note: 1: These bits can not be modified as long as LOCK level 3 has been programmed

(LOCK bits in TIMx_BDTR register) and

CC1S=00

(the channel is configured in

output).

And CC1S bit:

 

 

Note: CC1S bits are

writable only when the channel is OFF

(CC1E = 0 in TIMx_CCER).

Function TIM_OC1PreloadConfig( TIMx, TIM_OCPreload) doesn't check it.

Timers 2, 3, 4, 5 don't have BDTR bit (developers, please correct RM!); but CCxS sets first than OCxPE if I catch it right.

t2399
Associate II
Posted on July 01, 2015 at 10:03

 Sorry, all.

I use GCC and of course utility 'make'. I didn't include 'stm32f4xx_it.c' in list compiled and linked files!

PS: Compiler didn't report about error. I hoped read it. Why? Usually, when I use global variables in interrupt, I declared its in file with interrupt body and use variable in main.c and other files. In the example variables declared in main.c . I know, my way is wrong but it can be usefully.