Need to display SYSCLK frequency setting route for STM32F103C8. There are initial data:
SYSCLK = 64MHz; HSE generator; AHB Pre = 8 ; MCO - HSI.
I got the following route -> image with route
But it turned out to be incorrect, since the configured frequency should be 9Mhz. But I don't understand why not 8Mhz.
Where did I go wrong?
You have indicated that you selected HSI as the MCO. HSI has a fixed frequency of 8MHz, so you should expect 8MHz on the pin.
The only way you can make 9MHz is to use the PLL to multiply the 8MHz crystal by 9 to get 72MHz, and then set one of the bus dividers to 8. This will give you 9MHz on the AHB or APB.
The diagram appears to show that the SYSCLK output from the MCO is taken before AHB divider, so even if you have a 9MHz AHB, you cannot get 9MHz on the MCO.
Related
Here's my configuration:
GPIO_InitTypeDef GPIO_InitStruct = {0};
GPIO_InitStruct.Pin = 8;
GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOJ, &GPIO_InitStruct);
When I put the signal on the input pin (square, 2Hz, 3.3Vp-p) I get an interrupt every 250ms, so - on every RISING and falling edge of the signal. I changed the test signal duty cycle to test if it's really what is happening and it confirmed it. I get the interrupt on both edges.
I even debugged the HAL driver to test if it does what I think it does. And yes, it seems to configure the EXTI correctly, only for the falling edge for my pin.
What may be the cause of such behavior? My device is STM32H747I-DISCO discovery board with TouchGFX software used for presentation. The software works correctly, I tested it on measuring the time between other timer interrupts.
I monitor the test signal on the oscilloscope to ensure the input signal on my pin is correct. I tried to use another pin on the same port, but I observe identical behavior. I get interrupts on both rising and falling edges of the signal, despite the pin is configured to trigger the interrupt only on the falling edge.
I also tested the case with the rising edge only. Also in this case I get the interrupt on both edges.
The problem turned out to be a hardware error, a voltage spike I overlooked. The STM32 EXTI input worked correctly all the time. There was indeed a spurious falling edge.
Simulated problem illustration, the 10n capacitor causes voltage spikes and spurious edge detection. In the real circuit, when a digital oscilloscope was used and the time base was too long to capture the spike - the signal looked like a proper square wave. After shortening the time base I noticed the spike. As it is shown on the illustration, this behavior can be easily simulated in a circuit simulator:
SIMULATION LINK
Removing the capacitor from the circuit solved the problem.
To avoid getting noise and other spurious signals on the input shielded wires can be used. The real world circuit was tested and it works properly without the capacitor.
The opto-coupler is just a simplified model of the optical sensor used in the real machine.
We are using STM32CubeMX to generate the initial code for ADC pin-matching.
In our particular case, all of the 16 available pins- that is, PA0 to PA7, PB0 to PB1, and PC0 to PC5- in the ADC1 mode are used. It is interesting yet absurd to find that while all the other pins generate the normal voltage values(varing from 1500 to 3000), PB0 outputs 0 constantly and PB1 outputs 4040 averagely.
We have examined multiple times and we are pretty sure the problem isn't on our external sensor. Meanwhile, we have used a second board(identical model number), however, the same issue reoccurred. We exerted ourselves to fix the problem yet still trapped by it.
CubeMX initialization pic1
CubeMX initialization pic2
I want to generate clock for PCA9959 LED driver with my STM32L552. The LED driver needs an external clock at 20 MHz (+/- 15%). I'm trying to generate a 22 MHz clock on port PA8 on STM32L552. I managed to generate a PWM on port PA8, but I can't reach the frequency of ~22Mhz. I arrive at a maximum of 8Mhz.
Here are the PWM parameters:
I'm not sure I filled in the pwm parameters correctly. Normally with his settings I guess I should have a 22 MHz PWM with a 20% duty cycle.
PWM (MHz) = SystemCoreClock (MHz) / Prescaler => 22MhZ = 110MHz / 5
My clock configuration:
Thanks for your help.
The easiest way to output a high speed clock like this is with the MCO peripheral, rather than a timer. Fortunately for you the MCO pin is PA8. Perhaps the person who designed your board knew this and intended you to use MCO. Read the reference manual to see how.
If you do want to use a timer to do 22MHz, then as you have correctly identified you cannot get a 50% duty-cycle on your PWM. I would recommend starting with a 40% or 60%, with an output-compare value of 2-out-of-5 or 3-out-of-5, not 1 as you have above.
There is no detail in the PCA9959 datasheet about what the required mark-space ratio of the clock is, but I guess anything other than 50% could be a problem. You would be better to divide the clock by an even number. Either just divide 110MHz by 6 and output 18.33MHz, or else slow your core down a bit and divide by 4 (reduce the N parameter of your PLL).
Whether you use MCO or PWM don't forget to set the GPIO pin mode to the fastest slew rate available. Maybe the 8MHz you are measuring is the result of aliasing a faster clock that has been through the wrong GPIO mode. You could test this using a scope with at least 100MHz bandwidth.
The clock configurator in STM32CubeMX does not allow the PLL divider DIVP1 frequency to exceed 300MHz so it is impossible to use it to achieve the board's maximum of 480MHz. To do this you must go into the code for the configurator and manually change the multipliers. Is this confusion on my part or an error with the data provided by ST for the board?
Checking CPU performance singing a hardcoded assembler timing loop the subtract and branch instructions of the timing circuit take two clock cycles. On my Nucleo-H723ZG board these two take a total of one cycle. Is DUAL ISSUING not available on H743?
Once again in the STM32CubeMX in the System RCC section Master_Clock_Output_1 is highlighted in RED. (Conflict with: USB_OTG_FS: Activate_SOF). What is this all about?
You need to have the correct voltage scale (VOS) which affects the maximum clock directly. To clock this device at 480MHz.
As for your pin conflict - the MCO pin is a clock output to use for clocking external devices. Pins in the STM32 chip can be multiplexed such that they can serve multiple functions, such as ADC1_CH4 GPIO_OUT etc... You have a conflict that 1 pin is trying to facilitate 2 functionalities, and such you have a conflict. rearrange the functionality or pin to fix the conflict.
I am currenctly working on STM32L052K6T6.
I would like to know if there is an appropriate way to measure precisely the voltage used by the adc.
I read through the documentation that this voltage was on adc_channel17 but i have no idea on how to get it.
I also read there was a calibration Variable called VREFINT_CAL but again i did'nt see the process to use it properly.
I know this voltage is for me around 1.8V. But i need to know it untill 1.80000 at least to calculate accurate values of my sensor.
To program my MUC i am using Atollic, i did the basic pins configuration using STM32CubeMX.
The internal reference voltage is not used by the ADC. It is only used to measure the actual Vref voltage. Vref voltage depending on the version of the chip can be Vref+ or Vdda.
How to measure the actual Vref?
You need to measure the Vrefint (which is about 1.2V) and then using the simple math calcultate the Vref
Vrefint = Vref * (RAW_ADC / 4096)
So Vref = Vrefint * 4096 / RAW_ADC
or if you want to use VREFINT_CAL : Vref = 3 V * VREFINT_CAL / RAD_ADC
You have to do a calibration before measuring good value of channel VREF_INT.
HAL_ADCEx_Calibration_Start(&hadc, ADC_SINGLE_ENDED);