![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
mojsa2000
Joined: 18 May 2010 Posts: 78
|
I cant understand these warnings |
Posted: Sat Aug 07, 2010 2:03 pm |
|
|
Hi
I've made a program by PIC16f877a. I used a/d & timer0 and ds1307 & lcd functions.
When I compiled the project these warnings occurred:
Code: |
>>> Warning 216 "final.c" Line 317(0,1): Interrupts disabled during call to prevent re-entrancy: (@DIV88)
>>> Warning 216 "final.c" Line 317(0,1): Interrupts disabled during call to prevent re-entrancy: (@MULFF)
>>> Warning 216 "final.c" Line 317(0,1): Interrupts disabled during call to prevent re-entrancy: (@ADDFF)
|
I never used a function in ISR. I used many many flags in ISRs.
Code: |
#include <16f877a.h>
#FUSES XT,NOWDT,PUT,BROWNOUT,NOLVP
#DEVICE ADC=10
#use delay (clock=4000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
#include <I:\ELECTRONICS\PIC\My sources\ds1307.c>
#include <I:\ELECTRONICS\PIC\My sources\24c512.c>
#include <I:\ELECTRONICS\PIC\My sources\memory_pointers_maker.c>
#include <I:\ELECTRONICS\PIC\My sources\flex_lcd.c>
static float read_AD,v_average=0,i_average=0;
static float hourly_v=0,hourly_i=0;
static float daily_v=0,daily_i=0;
static float hourly_positive_power=0,hourly_negative_power=0;
static float daily_positive_power=0,daily_negative_power=0;
static float hourly_VI_value=0;
static float daily_VI_value=0;
static float v_dc_ave,i_dc_ave;
//********************* All flags *******************************************
int1 half_min_flag;//a flag for checking that 30 seconds are passed
int1 one_min_flag;
int1 ten_min_write_to_eeprom;
int1 hour_write_to_eeprom;
int1 day_write_to_eeprom;
int1 first_time_flag_check=0;
int1 first_time_flag_check_for_hour=0;
int1 first_time_flag_check_for_day=0;
//*****************************************************************************
unsigned int8 half_min_counter=0;
unsigned int8 one_min_counter=0;
unsigned int16 v_memory_pointer,i_memory_pointer;
unsigned int16 hourly_pos_VI_memory_pointer,hourly_neg_VI_memory_pointer;
unsigned int16 daily_pos_VI_memory_pointer,daily_neg_VI_memory_pointer;
int8 shift_to_right_counter;
//**************** setting up ds1307 ******************
//*****************************************************
int8 sec;
int8 min;
int8 hour;
int8 day;
int8 month;
int8 year;
int8 dow;
//*
int channel;
#int_AD
void AD_isr(void)
{
channel++;//choose wich cannel is reading
read_AD=read_adc(ADC_READ_ONLY);
if (channel==1)//read channel(0)_reserved for voltage
{
v_average=(read_AD+v_average)/2; //make an average of voltage
v_dc_ave=v_average*5/1023;
//make true voltage from its formul
}
if(channel==2)//read channel(1)__reserved for current
{
i_average=(read_AD+i_average)/2;//make an average of current
i_dc_ave=i_average*5/1023;
channel=0;
}
}
//**************************************************************
//**************************************************************
//************************* RTCC INT START ******************
//**************************************************************
#int_RTCC
void RTCC_isr(void)
{
half_min_counter++;
one_min_counter++;
if (min%10==0)
{
if(!first_time_flag_check)
{
ten_min_write_to_eeprom=1;
first_time_flag_check=1;
break;
}
}
else
first_time_flag_check=0;
//**************************************
if (min==0)
{
if(!first_time_flag_check_for_hour)
{
hour_write_to_eeprom=1;
first_time_flag_check_for_hour=1;
}
}
else
first_time_flag_check_for_hour=0;
//****************************************
if(hour==0)
{
if(!first_time_flag_check_for_day)
{
day_write_to_eeprom=1;
first_time_flag_check_for_day=1;
}
}
else
first_time_flag_check_for_hour=0;
//****************************************
if(half_min_counter==30)
{
half_min_flag=1;
half_min_counter=0;
}
if(one_min_counter==60)
{
one_min_flag=1;
one_min_counter=0;
}
}
//*****************************************************
//******************** RTCC INT END *******************
//*****************************************************
void shifting_to_right()
{
for(shift_to_right_counter=0;shift_to_right_counter<16;shift_to_right_counter++)
{
shift_to_right();
delay_ms(150);
}
}
float read_hourly_vi(int16 hour,int16 day)
{
hourly_pos_VI_memory_pointer_func(hour,day);
hourly_positive_power=eeprom_read(hourly_pos_VI_memory_pointer);
hourly_neg_VI_memory_pointer_func(hour,day);
hourly_negative_power=eeprom_read(hourly_neg_VI_memory_pointer);
return hourly_positive_power ,hourly_negative_power;
}
float read_daily_vi(int16 day)
{
daily_pos_VI_memory_pointer_func(day);
daily_positive_power=eeprom_read(daily_pos_VI_memory_pointer);
daily_neg_VI_memory_pointer_func(day);
daily_negative_power=eeprom_read(daily_neg_VI_memory_pointer);
return daily_positive_power,daily_negative_power;
}
void a2d_set()
{
//********* set up the A/D module *************
set_adc_channel(0);
read_adc(ADC_START_ONLY);
delay_ms(2);
set_adc_channel(1);
read_adc(ADC_START_ONLY);
delay_ms(2);
////**********************************************
}
void main()
{
enable_interrupts(INT_AD);
enable_interrupts(INT_EXT);
enable_interrupts(INT_RTCC);
enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);
setup_adc_ports(AN0_AN1_AN3);
setup_adc(ADC_CLOCK_DIV_8);
setup_comparator(NC_NC_NC_NC);
ext_int_edge( H_TO_L );
setup_spi(SPI_MASTER|SPI_L_TO_H|SPI_CLK_DIV_4);
setup_timer_0(RTCC_EXT_H_TO_L|RTCC_DIV_32);
set_timer0(0);
ds1307_init();
delay_ms(100);
lcd_init();
// Set date for -> 15 July 2005 Tuesday
// Set time for -> 15:20:55
//ds1307_set_date_time(5,8,10,6,5,20,0);
ds1307_get_date(day,month,year,dow);
ds1307_get_time(hour,min,sec);
lcd_putc("Start...");
while(1)
{
printf("salam");
a2d_set();
if(half_min_flag)
{
ds1307_get_date(day,month,year,dow);
ds1307_get_time(hour,min,sec);
half_min_flag=0;
//**********************
if (ten_min_write_to_eeprom)
{
v_memory_pointer_func(hour,min,day);
i_memory_pointer_func(hour,min,day);
eeprom_write(i_dc_ave,i_memory_pointer);
eeprom_write(v_dc_ave,v_memory_pointer);
hourly_v+=v_dc_ave;
hourly_i+=i_dc_ave;
ten_min_write_to_eeprom=0;
//********************************
if(hour_write_to_eeprom)
{
hourly_VI_value=hourly_v*hourly_i;
daily_v+=hourly_v;
daily_i+=hourly_i;
hourly_v=0;
hourly_i=0;
hourly_pos_VI_memory_pointer_func(hour,day);
hourly_neg_VI_memory_pointer_func(hour,day);
if(hourly_VI_value>=0)
{
eeprom_write(hourly_VI_value,hourly_pos_VI_memory_pointer);
eeprom_write(0,hourly_neg_VI_memory_pointer);
}
//*****************************************
if(hourly_VI_value<0)
{
eeprom_write(hourly_VI_value,hourly_neg_VI_memory_pointer);
eeprom_write(0,hourly_pos_VI_memory_pointer);
}
hour_write_to_eeprom=0;
//******************************************************************
//*****************************************************************
}
if(day_write_to_eeprom)
{
daily_VI_value=daily_v*daily_i;
daily_v=0;
daily_i=0;
daily_pos_VI_memory_pointer_func(day);
daily_neg_VI_memory_pointer_func(day);
if(daily_VI_value>=0)
{
eeprom_write(daily_VI_value,hourly_pos_VI_memory_pointer);
eeprom_write(0,hourly_neg_VI_memory_pointer);
}
if(daily_VI_value<0)
{
daily_neg_VI_memory_pointer_func(day);
eeprom_write(daily_VI_value,hourly_neg_VI_memory_pointer);
eeprom_write(0,hourly_pos_VI_memory_pointer);
}
day_write_to_eeprom=0;
}
}
}
if(one_min_flag)
{
lcd_clear();
lcd_gotoxy(1,1);
printf(lcd_putc,"Date: 20%u/%u/%u",year,month,day);
lcd_gotoxy(1,2);
printf(lcd_putc,"Time: %02u:%02u",hour,min);
delay_ms(2000);
shifting_to_right();
read_hourly_vi(hour,day);
lcd_clear();
lcd_gotoxy(1,1);
printf(lcd_putc,"+P(Hour): %5.3f",hourly_positive_power);
lcd_gotoxy(1,2);
printf(lcd_putc,"-P(Hour): %5.3f",hourly_negative_power);
delay_ms(2000);
shifting_to_right();
read_daily_vi(day);
lcd_clear();
lcd_gotoxy(1,1);
printf(lcd_putc,"+P(Day): %5.3f",daily_positive_power);
lcd_gotoxy(1,2);
printf(lcd_putc,"-P(Day): %5.3f",daily_negative_power);
delay_ms(2000);
shifting_to_right();
one_min_flag=0;
}
}
} |
|
|
![](templates/subSilver/images/spacer.gif) |
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Sat Aug 07, 2010 3:48 pm |
|
|
I guess, the question has been answered a dozen times at CCS forum.
You don't use functions in the ISR, but the compiler does to handle the float arithmetic. You can see in the symbol file that these routines are using RAM data as scratch memory. As a consequence, they are not reentrant. When non-reentrant functions are used in interrupt handlers, the compiler guards all function calls by globally disabling interrupts. Because the application performance may be affected (e.g. by increasing interrupt latency), the compiler issues a warning. |
|
![](templates/subSilver/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|