Hi I am new to Arduino and i want to write these two pieces of interrupt codes to arduino but i get back error messages can anyone help me ?
//timer 0 compare ISR
interrupt ([TIM0_COMP] void timer0_compare(void))
{
if(~PINB & 0x01) timepress0++;
if(~PINB & 0x02) timepress1++;
if(~PINB & 0x04) timepress2++;
timecount++;
timedeflate++;
//Decrement each time tast if they are not already zero
//timing for sampling data at every 40 msec
if(timing>0) --timing;
//-----------------------------------------------------
//run time for different tasks
//run timerate for measuring heart rate
if(timerate<6000) ++timerate;
//run timerun_dias
if(timerun_dias<2000) ++timerun_dias;
//if(countlcd) timelcd++;
//run time for the display
if(timedisplay<2000) ++timedisplay;
}
//***********************************************
// ADC Interrupt
//**********************************************************
interrupt [ADC_INT] void adc_complete(void)
{
data = ADCH;
//then calculate adc_data into float;
adc_data = (float)(((float)data)/256*Vref);
//if signal is above threshold, go to calculate systolic pressure
if(meas_state ==Sys_Measure)
{
if(former<=TH_sys && adc_data>TH_sys)
sys_count++;
former = adc_data;
}
//-----------------------------------------------------------
else if(meas_state==Sys_Cal)
{
if(count<4)
{
accum_data=accum_data+adc_data;
count++;
}
if(count==4)
{
press_data=accum_data/4;
systolic = (press_data/DC_gain)*9375;//calculate from adc_data
meas_state = Rate_Measure;
countpulse=0;
former = 2.4; //set the initial point for rate measuring
count_average=0;
}
}
//----------------------------------------------------------
else if(meas_state==Rate_Measure)
{
if(count_average<5)
{
if(former<TH_rate && adc_data>TH_rate && countpulse==0)
{
timerate=0;
countpulse=1;
former=adc_data;
}
if(former<TH_rate && adc_data>TH_rate && countpulse==1)
{
total_pulse_period=total_pulse_period+timerate;
timerate=0;
count_average++; //finish reading one period
}
}//count_average
former=adc_data;
}// else if(meas_state=Rate_Measure)
//-------------------------------------------------------------
else if(meas_state==dias_Measure)
{
if(timerun_dias<2000)
{
if(adc_data>TH_dias)
{ timerun_dias=0; //reset time if the signal
//is still greater than threshold (so it will never reach 1999)
//if it doesn't reset,the time will stuck at 1999
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Dias measure");
}
}
if(timerun_dias>=2000)
{
meas_state = dias_Cal;//if done go back to Sys_Measure to be ready for next opt
}
}
//-------------------------------------------------------------
else if(meas_state==dias_Cal)
{
diastolic = (adc_data/DC_gain)*9375;//calculate from adc_data
meas_state = Sys_Measure;
currentState = displayState;
//open valve
PORTD=0;
}
timing = 40;//set time for another conversion
}
// end of ADC interrupt
//***********************************************************