AnsweredAssumed Answered

Finding period of a square wave using Input Capture

Question asked by Mohammad Shekarforoush on Jan 8, 2011
Latest reply on Jan 10, 2011 by Mohammad Shekarforoush

I'm trying to find the period of a external square wave using the input capture interrupt.

There is one line of code causing the below error message and its driving me mad. The error is caused by the following line:

    actual_period = period/6000000;

 

The code works fine if I remove this line. But then I have to use a calculator to find the actual period every time.

Please Help. I'm not a very good programmer.


Here is the error message:

 

C4000: Condition always TRUE

main.c line 35   

Link Error   : L1822: Symbol _FSFLOAT in file C:\Documents and Settings\Mo\Desktop\Lakehead_U\Project\Input Capture\input capture\input_capture_Data\Standard\ObjectCode\main.c.o
is undefined


Link Error   : Link failed

 

 

Here is the code:

 

 

#include <hidef.h>      /* common defines and macros */#include "derivative.h"      /* derivative-specific definitions */volatile unsigned int rising, period;volatile unsigned int flag;#pragma CODE_SEG __NEAR_SEG NON_BANKED /* Interrupt section for this module.Placement will be in NON_BANKED area. *//* Interrupt on a rising edge of waveform connected to PT0 */interrupt void toc0_isr(void){       flag ++;    if(flag == 1)       rising=TC0;      if (flag == 2)    period = TC0 - rising;        if (flag == 3)    flag = 0;    }#pragma CODE_SEG DEFAULTvoid input_capture_initialize(void); /* prototype to initialize input capture */void main(void) {                             float actual_period;    DDRT = 0xFE;    /* PT0 is input, all the rest are unchanged */    flag = 0;    input_capture_initialize();    EnableInterrupts; /* clear I bit of CCR */    while(1)    {       actual_period = period/6000000;    }      }            void input_capture_initialize(void){  TSCR1=0x90; /* enable timer and fast clear, rather than writing to bit0 of TFLG1 */  TSCR2=0x02; /* prescale to 4  6000000 pps, longest pulse width measured using*/                  TIOS=0x00;  /* select input capture (all channels) */  TCTL3=0x00; /* capture disabled on channels 4 to 7 */  TCTL4=0x01; /*PORTT0 capture on rising edge, channels 1 to 3 disabled */  TIE=0x01;   /* enable timer interrupt on C0 */}

 

 




Outcomes