Zur Übersicht - INFO - Neueste 50 Beiträge - Neuer Beitrag - Suchen - Zum C-Control-I-Forum - Zum C-Control-II-Forum

Re: RPM Kategorie: CC-Pro Unit & Appl.Board (von Bram Vooys - 1.01.2017 20:38)
Ich nutze:
C-Control Pro Mega32
I want to measure the time between two pulses, from a Hall sensor.  and send it via Rs232 to the PC.
To be used For measuring of an engine speed.
Code:
word PM_Value;
void Timer1_ISR(void)
{
    int irqcnt;
    PM_Value=Timer_T1GetPM();
    irqcnt=Irq_GetCount(INT_TIM1CAPT);
}

void main(void)
{
    byte n;
    Serial_Init(0,SR_8BIT|SR_1STOP|SR_NO_PAR,SR_BD9600);  
    Irq_SetVect(INT_TIM1CAPT,Timer1_ISR);
    Timer_T0PWM(100,PS0_64);   // Start Pulse Generator Timer 0
 // Measurement starts here
 // Output Timer0 OC0(PortB.3) connect to ICP(input capture pin, PortD.6)
    PM_Value=0;
 // Set mode to Pulse Width Measurement and determine prescaler
    Timer_T1PM(0,PS_64);
    while(PM_Value==0);     // Measure Pulse Width or Period
    Serial_Write(0,PM_Value); // Output Measuring Value
}
Is an there incorrect in this code?
Regards, Bram


    Antwort schreiben


Antworten: