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 */}
Solved! Go to Solution.
_FSFLOAT is integer to float conversion routine. Clearly you told project wizard you don't want floating point. You probably selected 'None' for promised best code density :smileyhappy:. You should either 1) recreate project and select double is 32bits or 64bits, but not None. Or 2) remove integer only ansixxx.lib from your project, read <CW root>\lib\hc12c\readme.txt and add appropriate library with FP support.
volatile unsigned int period;
float actual_period;
actual_period = period/6000000;
Clearly actual_period will be always 0.0. To make it not zero, you should typecast dividend, divisor, or both them to float.
actual_period = (float)period/6000000;
P.S. Subject has very little to do with the problem. "undefined _FSFLOAT" would be better. But again, it is a Codewarrior usage issue, not 16-bit MCU. Please use right forum next time.
_FSFLOAT is integer to float conversion routine. Clearly you told project wizard you don't want floating point. You probably selected 'None' for promised best code density :smileyhappy:. You should either 1) recreate project and select double is 32bits or 64bits, but not None. Or 2) remove integer only ansixxx.lib from your project, read <CW root>\lib\hc12c\readme.txt and add appropriate library with FP support.
volatile unsigned int period;
float actual_period;
actual_period = period/6000000;
Clearly actual_period will be always 0.0. To make it not zero, you should typecast dividend, divisor, or both them to float.
actual_period = (float)period/6000000;
P.S. Subject has very little to do with the problem. "undefined _FSFLOAT" would be better. But again, it is a Codewarrior usage issue, not 16-bit MCU. Please use right forum next time.
Thank you very much.
The problem is fixed.
I will try to use the proper forum next time.