Oct 20, 2014 #1 B btbass Advanced Member level 5 Joined Jul 20, 2001 Messages 1,896 Helped 438 Reputation 880 Reaction score 288 Trophy points 1,363 Location Oberon Visit site Activity points 12,887 I have a STM32F405 and I need to toggle an I/O pin at 20MHz. Could anybody suggest how to do this? Would inline assembler be the answer? If so, how?
I have a STM32F405 and I need to toggle an I/O pin at 20MHz. Could anybody suggest how to do this? Would inline assembler be the answer? If so, how?
Oct 20, 2014 #2 M milan.rajik Banned Joined Apr 1, 2013 Messages 2,524 Helped 540 Reputation 1,078 Reaction score 524 Trophy points 1,393 Visit site Activity points 0 Which Compiler are you using ? You can use Timer to toggle the pin.
Oct 20, 2014 #3 Venkadesh_M Advanced Member level 4 Joined Jun 26, 2013 Messages 1,374 Helped 258 Reputation 516 Reaction score 254 Trophy points 1,363 Location Coimbatore, India Visit site Activity points 8,020 What is the maximum value of peripheral clock frequency? What Oscillator frequency you have chosen ? What is the minimum prescalar for Timer ? - - - Updated - - - Here is some example code, STM32F4: Timer The timer can operate in the peripheral frequency of 168MHz, but obviously you can not use this code because it will have lot of delays when interpreting c to assembly, So you have to use PWM.
What is the maximum value of peripheral clock frequency? What Oscillator frequency you have chosen ? What is the minimum prescalar for Timer ? - - - Updated - - - Here is some example code, STM32F4: Timer The timer can operate in the peripheral frequency of 168MHz, but obviously you can not use this code because it will have lot of delays when interpreting c to assembly, So you have to use PWM.
Oct 20, 2014 #4 B btbass Advanced Member level 5 Joined Jul 20, 2001 Messages 1,896 Helped 438 Reputation 880 Reaction score 288 Trophy points 1,363 Location Oberon Visit site Activity points 12,887 Thanks for the replies, I will look at the sample code. I am using EmBlocks and the bare metal GCC compiler. My core clock is 168MHz and the peripheral clock is 84MHz. I have tried using the timer and also PWM. The fastest I can go with these methods is ~2MHz? Using C, if I just toggle the pin, I get < 2MHz. while(1) { GPIO_SetBits(GPIOC, GPIO_Pin_12); GPIO_ResetBits(GPIOC, GPIO_Pin_12); } I think I need inline assembler?
Thanks for the replies, I will look at the sample code. I am using EmBlocks and the bare metal GCC compiler. My core clock is 168MHz and the peripheral clock is 84MHz. I have tried using the timer and also PWM. The fastest I can go with these methods is ~2MHz? Using C, if I just toggle the pin, I get < 2MHz. while(1) { GPIO_SetBits(GPIOC, GPIO_Pin_12); GPIO_ResetBits(GPIOC, GPIO_Pin_12); } I think I need inline assembler?
Oct 20, 2014 #5 Venkadesh_M Advanced Member level 4 Joined Jun 26, 2013 Messages 1,374 Helped 258 Reputation 516 Reaction score 254 Trophy points 1,363 Location Coimbatore, India Visit site Activity points 8,020 I will have a view on STM32F405 it look easy to do with PWM. Doing with assembly will also difficult in case of 32 bit controllers. So better you stick with PWM. In LPC series you can generate 1/4 peripheral frequency, but still it will come like 164 / 8 = 20.5MHZ Otherwise you have to select a peripheral frequency like 160MHz.. I will confirm the possibility after looking at manual.
I will have a view on STM32F405 it look easy to do with PWM. Doing with assembly will also difficult in case of 32 bit controllers. So better you stick with PWM. In LPC series you can generate 1/4 peripheral frequency, but still it will come like 164 / 8 = 20.5MHZ Otherwise you have to select a peripheral frequency like 160MHz.. I will confirm the possibility after looking at manual.