Googlespeedtest

Image

Speedtest

void QTMR_IRQhandler(void){QTMR_ClearStatusFlags(TMR3, kQTMR_Channel_0, kQTMR_EdgeFlag);qtmrIsrFlag = true;__DSB();}/** @brief Application entry point.*/int main(void) {qtmr_config_t qtmrConfig;uint32_t timeCapt = 0;uint32_t count = 0;uint32_t tacho_freq = 0;uint32_t RPM =0;

But the issue is when i connect the tacho signal form the fan, firmware can't measure the tacho signal anymore. It shows some gurabge value. How to solve this issue??Please help.

Internetspeedtest

The code looks fine, otherwise, it wouldn't work with the signal generator either. So, it seems that the problem is with the fan signal. How does this signal look in an oscilloscope? Can you measure the frequency of the fan signal with an oscilloscope? If so, what happens if you generate this frequency with the signal generator? Are you able to measure it? What is the voltage of the fan signal?

speedtest测速

while(1){timeCapt=TMR3->CHANNEL[kQTMR_Channel_0].CAPT;PRINTF("\r\ntimeCapt=%d\n",timeCapt);PRINTF("\r\ntacho_freq=%d Hz\n", tacho_freq = QTMR_SOURCE_CLOCK/timeCapt);PRINTF("\r\nFAN_SPEED=%d RPM\n", RPM = tacho_freq*60/2);SDK_DelayAtLeastUs(1000000, SDK_DEVICE_MAXIMUM_CPU_CLOCK_FREQUENCY);}

/* Init board hardware. */BOARD_ConfigMPU();BOARD_InitBootPins();BOARD_InitBootClocks();BOARD_InitBootPeripherals();#ifndef BOARD_INIT_DEBUG_CONSOLE_PERIPHERAL/* Init FSL debug console. */BOARD_InitDebugConsole();#endif

/* TODO: insert other definitions and declarations here. */#define QTMR_BASEADDR TMR3#define QTMR_INPUT_CAPTURE_CHANNEL kQTMR_Channel_0#define QTMR_Counter_InputPIn kQTMR_Counter0InputPin

}// With this code i can measure the external signal from signal generator. Even when i change the input signal frequency from signal generator, firmware can detect the updated signal frequency//

-------------------------------------#include #include "board.h"#include "peripherals.h"#include "pin_mux.h"#include "clock_config.h"#include "MIMXRT1052.h"#include "fsl_debug_console.h"#include "fsl_qtmr.h"/* TODO: insert other include files here. */

/* Check whether occur interrupt and wait the capture frequency stable */while (count<5 || timeCapt == 0){while (!(qtmrIsrFlag)){}qtmrIsrFlag = false;count++;timeCapt=TMR3->CHANNEL[kQTMR_Channel_0].CAPT;}