2020-12-10 02:50 AM
This is my code so far.
I solved the clock frequency of 72MHz with an excel sheet and imported the file which got created, so that is working. My HSE Speed is 8 Mhz.
Now i dont get how to mirror the System Clock onto the MCO output pin.
This is what i tried...
Can you guys help me?
I am really new to MCU Programming.
We are working with a STM32F407VG
Thanks in advance!
________________________________________________________________________________
#include "stm32f4xx.h"
#include "stm32f4xx_gpio.h"
#include "stm32f4xx_rcc.h"
#define HSE_VALUE (uint32_t)8000000
GPIO_InitTypeDef GPIO;
int main(void)
{
int i = 0;
SystemInit();
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);
GPIO.GPIO_Mode = GPIO_Mode_AF;
GPIO.GPIO_OType = GPIO_OType_PP;
GPIO.GPIO_Speed = GPIO_Speed_50MHz;
GPIO.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO.GPIO_Pin = GPIO_Pin_9;
GPIO_Init(GPIOC, &GPIO);
//GPIO_SetBits(GPIOC, GPIO_Pin_9);
while (1)
{
i++;
}
}
2020-12-10 05:54 AM
You should be able to select this configuration within CubeMX and have it generate the code. MCO output can be selected within System Core -> RCC.
2020-12-10 07:01 AM
Thanks for you answer.
I didnt know this software exists.
Sadly we are not allowed to work with it...
But still i managed to get the code out of it
thanks
2020-12-10 08:00 AM
/**
* @brief Output System Clock on MCO2
* @param None
* @retval None
*/
void MCO2_Config(void)
{
GPIO_InitTypeDef GPIO_InitStructure = {0};
/* Config MCO2 PC9 to Alternate function */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);
GPIO_PinAFConfig(GPIOC, GPIO_PinSource9, GPIO_AF_MCO);
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
/* MCO CLK pin configuration */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
GPIO_Init(GPIOC, &GPIO_InitStructure);
RCC_MCO2Config(RCC_MCO2Source_SYSCLK, RCC_MCO2Div_5); // Select divider from available options
}
2020-12-10 08:17 AM
2020-12-10 08:19 AM
Okay thanks to you all it works :)