Mehmet Fide

Using a function in timer ISR and main at the same time?

Discussion created by Mehmet Fide on Sep 1, 2007
Latest reply on Sep 4, 2007 by Daniel Lundin
Hi,
 
I have a C project for LC60. And I need to use ProcessBitFilter() function in ISR and main. For my previous project, when I was using Microchip PIC and Hitech C, this was caused some problems.
 
Is this same limitation is valid also for CW C in HCS08 platform?
 
Thank you.
 
Code:
typedef struct {  unsigned char instant_bit_status:1;  unsigned char filtered_bit_status:1;  unsigned char on_filtered_bit_changed:1;  unsigned char on_filtered_bit_down:1;  unsigned char on_filtered_bit_up:1;  unsigned char R5:1;  unsigned char R6:1;  unsigned char R7:1;   unsigned char occurrence_time0;   unsigned char filter_time0;    unsigned char occurrence_time1;   unsigned char filter_time1;} TBitFilter;void ProcessBitFilter(TBitFilter* Filter, unsigned char instant_bit_value){ Filter->instant_bit_status = instant_bit_value;  if((Filter->instant_bit_status) != (Filter->filtered_bit_status)) {  if(Filter->instant_bit_status)  {   //     if(++Filter->occurrence_time1 >= Filter->filter_time1)    {    Filter->filtered_bit_status = Filter->instant_bit_status;       Filter->occurrence_time1 = 0;        Filter->on_filtered_bit_changed = 1;    Filter->on_filtered_bit_up = 1;    }  } else  {   //    if(++Filter->occurrence_time0 >= Filter->filter_time0)    {    Filter->filtered_bit_status = Filter->instant_bit_status;    Filter->occurrence_time0 = 0;        Filter->on_filtered_bit_changed = 1;    Filter->on_filtered_bit_down = 1;   }  }   } else  {  //  Filter->occurrence_time0 = 0;  Filter->occurrence_time1 = 0; }}//////////////////////////////////////////////////////////////////////TBitFilter f_button, f_switch;interrupt VectorNumber_Vtpm1ovf void intTPM1OVF(void){ ... ProcessBitFilter(&f_button, tmp_button_menu); ...}void main(void){ while(1) {  ...  ProcessBitFilter(&f_switch, switch_status);  ... }}

 


Message Edited by BasePointer on 2007-09-01 02:39 PM

Outcomes