About the interrupt frequency of stm32duino?
Posted: Fri Apr 01, 2022 1:43 pm
Hi everyone, please forgive my poor english, here is my google translation. I am new to stm32duino, I am now going to count a 200khz pulse, originally I used arduino uno @16mhz, the rising edge of the pulse Triggering the interrupt counts in the interrupt and prints it through the serial port, but the counted value is not accurate and is smaller than the actual value. I think the frequency of 200 kHz may be too high, so the atmega328 crystal oscillator is replaced with 20mhz, and the value is accurate. Later, I used stm32f030 @48mhz and did not get the accurate value, and then I tried stm32g030 @64mhz, and the same value was obtained. They are all inaccurate values. Finally, the correct value is obtained by using stm32f103c6t6 @72mhz. I am confused why the crystal of atmega328p is 20mhz and cannot be count accurately, and the main frequency of stm32 is much higher than 20mhz. However, it cannot be counted accurately, Why? What am I missing? THX!!!
Below is the code, the code for atmega328p is the same
Below is the code, the code for atmega328p is the same
Code: Select all
int i = 0;
void count (void)
{
i++;
}
void setup()
{
Serial.begin(9600);
pinMode(PA4, INPUT_PULLUP);
attachInterrupt(PA4, count, RISING);
}
void loop()
{
Serial.println(i);
delay(3000);
}