CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

how to modify code and solve warning "prevent re-entran

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
whung.john
Guest







how to modify code and solve warning "prevent re-entran
PostPosted: Sat Sep 08, 2007 11:59 am     Reply with quote

hi my friends.
Sad
i try practice a program. but i compiled.
warning area display some informations.
information follow as:

interrupts disable during call to prevent re_entracce .[sendbit_1621]
interrupts disable during call to prevent re_entracce .[write_1621]
interrupts disable during call to prevent re_entracce .[@delay_ms1]
interrupts disable during call to prevent re_entracce .[@div88]

first question follow as:
i search my practice code.but only find interrupts timer1 have use "sendbit_1621" and "write_1621 "command.
i try addtion the "sendbit_1621" and "write_1621" into interrupt(timer1).
but thread become big from compile information.
so i dont know how to solve question.

second question.
the other warning ([@delay_ms1] and .[@div88]).
i cant find error code. have body can solve error area and teach me how to modify thread.

third question.
how can i save memory (ram and rom).because i compiled get use much
ram and rom .

my all thread follow as,hope to my friends can teach me .

#include <16F73.h>
#FUSES NOWDT, XT, NOPUT, NOPROTECT, NOBROWNOUT
#use delay(clock=4000000)
#define DAT PIN_C7
#define WR PIN_B0

#define bias 0x52
#define system 0x02
#define system_dis 0x00
#define lcdon 0x06
#define lcdoff 0x04
#define normal 0xc6

void sendbit_1621(unsigned char data,unsigned char cnt);
void senddatabit_1621(unsigned char data,unsigned char cnt);
void sendcmd(unsigned char command);
void write_1621(unsigned char addr,unsigned char data);
void writeall_1621(unsigned char addr,unsigned char *p,unsigned char cnt );
void all_display(void);
void ht1621_init(void);
void cls(void);
void kk_point(void);
void zero_timer(void);
void first_display(void);
void power_porg(void);
void timer_prog(void);

unsigned int seconds=0,mins=0;
const unsigned int setmins[7]={0,30,25,20,15,10,5};
unsigned timer_key1=0,timer_key2=0;
unsigned int setmins_key=0;
int16 int_count=0;
BYTE plag;
unsigned int keyscan;
unsigned int8 control_motorkey=0;
BYTE power_onoff=0;

const unsigned char timer_c1[2][10]={0x07,0x06,0x03,0x07,0x06,0x05,0x04,0x07,0x07,0x07,0x0D,0x00,0x0E,0x0a,0x03,0x0b,0x0f,0x00,0x0f,0x03};


void sendbit_1621(unsigned char data,unsigned char cnt)
{
unsigned char i;
for (i=0;i<cnt;i++)
{
if ((data&0x80)==0) output_low(DAT);
else output_high(DAT);
output_low(wr);
delay_cycles(1);
output_high(wr);
data<<=1;

}
}

void senddatabit_1621(unsigned char data,unsigned char cnt)
{
unsigned char i;
for (i=0;i<cnt>>=1;

}
}

void sendcmd(unsigned char command)
{
output_low(PIN_c5);
output_low(PIN_c6);

sendbit_1621(0x80,4);
sendbit_1621(command,8);
output_high(wr);

output_high(PIN_c5);
output_high(PIN_c6);



}

void write_1621(unsigned char addr,unsigned char data)
{
output_low(PIN_c5);
output_low(PIN_c6);

sendbit_1621(0xa0,3);
sendbit_1621(addr,6);
senddatabit_1621(data,4);

output_high(PIN_c5);
output_high(PIN_c6);


}

void writeall_1621(unsigned char addr,unsigned char *p,unsigned char cnt )
{
unsigned char i;

output_low(PIN_c5);
output_low(PIN_c6);


sendbit_1621(0xa0,3);
sendbit_1621(addr,6);
for (i=1;i<cnt;i++,p++)
{
senddatabit_1621(*p,8);
}
output_high(PIN_c5);
output_high(PIN_c6);

}

void cls(void)
{
unsigned int j;
for(j=0;j<128;j=j+3)
{
write_1621(j,0x00);
}
}

void all_display(void)
{
unsigned int j;
for(j=0;j<128>0)||(timer_key2>0))
{
if (timer_key1>0)
{
timer_key1=((setmins[setmins_key]-mins)/10);
}
timer_key2=((setmins[setmins_key]-mins)%10);
}


}

}

void timer_prog(void)
{
if (power_onoff==1)
{
disable_interrupts(INT_timer1);
zero_timer();
enable_interrupts(INT_timer1);
++setmins_key;
timer_key1=(setmins[setmins_key]/10);
timer_key2=(setmins[setmins_key]%10);
write_1621(36,timer_c1[0][timer_key1]);
write_1621(32,timer_c1[1][timer_key1]);
write_1621(44,timer_c1[0][timer_key2]);
write_1621(40,timer_c1[1][timer_key2]);
delay_ms(250);

if (setmins_key==6)
{
setmins_key=0;
}

}

}

void power_prog(void)
{
if (power_onoff==0)
{
sendcmd(lcdon);
first_display();
power_onoff=1;
delay_ms(250);
zero_timer();
setmins_key=0;
enable_interrupts(INT_timer1);
}
else
{
sendcmd(lcdoff);
power_onoff=0;
delay_ms(250);
cls();
disable_interrupts(INT_timer1);
}
}




void main()
{
unsigned int j;
const unsigned int keybord[3][2]= {1,0,
0,1,
1,1};

ht1621_init();
all_display();

for (j=1;j<=3;j++)
{
sendcmd(lcdon);
delay_ms(500);
sendcmd(lcdoff);
delay_ms(500);
}
cls();

setup_timer_1 ( T1_INTERNAL | T1_DIV_BY_1 );
disable_interrupts(INT_timer1
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_timer_2(T2_DISABLED,0,1);
enable_interrupts(GLOBAL);

while(1)
{
for (keyscan=0;keyscan<3;keyscan++)
{
output_bit(PIN_c5,keybord[keyscan][0]);
output_bit(PIN_c6,keybord[keyscan][1]);
if (!input(pin_b1) && (keyscan==2))
{
cls();
}
if (!input(pin_b2) && (keyscan==2))
{
write_1621(60,0x08);
}
if (!input(pin_b3) && (keyscan==2))
{
write_1621(60,0x04);
}
if (!input(pin_b4) && (keyscan==2))
{
write_1621(60,0x02);
}
if (!input(pin_b7) && (keyscan==0))
{
power_prog();
}
if (!input(pin_b7) && (keyscan==1))
{
timer_prog();
}
}

}
}
Ttelmah
Guest







PostPosted: Sat Sep 08, 2007 1:52 pm     Reply with quote

First, repost the question, using the 'code' controls round your code, and setting the tickbox 'disable HTML in this post'. Without these being done, your code is unreadable...
I also can't see the interrupt handlers in the post.
These are only warnings, and are not serious. Fixing them may well not be worthwhile (it means duplicating _all_ code that is used both in the interrupt handler and outside), and for code performing hardware operations, the interrupts _must_ be disabled, if you are to avoid having such controls in the main, interrupted by the one in the interrupt handler.

Best Wishes
WHUNG.JOHN
Guest







again display my code.
PostPosted: Sun Sep 09, 2007 4:54 am     Reply with quote

Code:

#include <16F73.h>
#FUSES NOWDT, XT, NOPUT, NOPROTECT, NOBROWNOUT
#use delay(clock=4000000)
#define DAT PIN_C7
#define WR PIN_B0

#define bias 0x52
#define system 0x02
#define system_dis 0x00
#define lcdon 0x06
#define lcdoff 0x04
#define normal 0xc6

void sendbit_1621(unsigned char data,unsigned char cnt);
void senddatabit_1621(unsigned char data,unsigned char cnt);
void sendcmd(unsigned char command);
void write_1621(unsigned char addr,unsigned char data);
void writeall_1621(unsigned char addr,unsigned char *p,unsigned char cnt );
void all_display(void);
void ht1621_init(void);
void cls(void);
void kk_point(void);
void zero_timer(void);
void first_display(void);
void power_porg(void);
void timer_prog(void);

unsigned int seconds=0,mins=0;
const unsigned int setmins[7]={0,30,25,20,15,10,5};
unsigned timer_key1=0,timer_key2=0;
unsigned int setmins_key=0;
int16 int_count=0;
BYTE plag;
unsigned int keyscan;
unsigned int8 control_motorkey=0;
BYTE power_onoff=0;

const unsigned char timer_c1[2][10]={0x07,0x06,0x03,0x07,0x06,0x05,0x04,0x07,0x07,0x07,0x0D,0x00,0x0E,0x0a,0x03,0x0b,0x0f,0x00,0x0f,0x03};


void sendbit_1621(unsigned char data,unsigned char cnt)
{
unsigned char i;
for (i=0;i<cnt;i++)
{
if ((data&0x80)==0) output_low(DAT);
else output_high(DAT);
output_low(wr);
delay_cycles(1);
output_high(wr);
data<<=1;

}
}

void senddatabit_1621(unsigned char data,unsigned char cnt)
{
unsigned char i;
for (i=0;i<cnt>>=1;

}
}

void sendcmd(unsigned char command)
{
output_low(PIN_c5);
output_low(PIN_c6);

sendbit_1621(0x80,4);
sendbit_1621(command,8);
output_high(wr);

output_high(PIN_c5);
output_high(PIN_c6);



}

void write_1621(unsigned char addr,unsigned char data)
{
output_low(PIN_c5);
output_low(PIN_c6);

sendbit_1621(0xa0,3);
sendbit_1621(addr,6);
senddatabit_1621(data,4);

output_high(PIN_c5);
output_high(PIN_c6);


}

void writeall_1621(unsigned char addr,unsigned char *p,unsigned char cnt )
{
unsigned char i;

output_low(PIN_c5);
output_low(PIN_c6);


sendbit_1621(0xa0,3);
sendbit_1621(addr,6);
for (i=1;i<cnt;i++,p++)
{
senddatabit_1621(*p,8);
}
output_high(PIN_c5);
output_high(PIN_c6);

}

void cls(void)
{
unsigned int j;
for(j=0;j<128;j=j+3)
{
write_1621(j,0x00);
}
}

void all_display(void)
{
unsigned int j;
for(j=0;j<128>0)||(timer_key2>0))
{
if (timer_key1>0)
{
timer_key1=((setmins[setmins_key]-mins)/10);
}
timer_key2=((setmins[setmins_key]-mins)%10);
}


}

}

void timer_prog(void)
{
if (power_onoff==1)
{
disable_interrupts(INT_timer1);
zero_timer();
enable_interrupts(INT_timer1);
++setmins_key;
timer_key1=(setmins[setmins_key]/10);
timer_key2=(setmins[setmins_key]%10);
write_1621(36,timer_c1[0][timer_key1]);
write_1621(32,timer_c1[1][timer_key1]);
write_1621(44,timer_c1[0][timer_key2]);
write_1621(40,timer_c1[1][timer_key2]);
delay_ms(250);

if (setmins_key==6)
{
setmins_key=0;
}

}

}

void power_prog(void)
{
if (power_onoff==0)
{
sendcmd(lcdon);
first_display();
power_onoff=1;
delay_ms(250);
zero_timer();
setmins_key=0;
enable_interrupts(INT_timer1);
}
else
{
sendcmd(lcdoff);
power_onoff=0;
delay_ms(250);
cls();
disable_interrupts(INT_timer1);
}
}




void main()
{
unsigned int j;
const unsigned int keybord[3][2]= {1,0,
0,1,
1,1};

ht1621_init();
all_display();

for (j=1;j<=3;j++)
{
sendcmd(lcdon);
delay_ms(500);
sendcmd(lcdoff);
delay_ms(500);
}
cls();

setup_timer_1 ( T1_INTERNAL | T1_DIV_BY_1 );
disable_interrupts(INT_timer1
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_timer_2(T2_DISABLED,0,1);
enable_interrupts(GLOBAL);

while(1)
{
for (keyscan=0;keyscan<3;keyscan++)
{
output_bit(PIN_c5,keybord[keyscan][0]);
output_bit(PIN_c6,keybord[keyscan][1]);
if (!input(pin_b1) && (keyscan==2))
{
cls();
}
if (!input(pin_b2) && (keyscan==2))
{
write_1621(60,0x08);
}
if (!input(pin_b3) && (keyscan==2))
{
write_1621(60,0x04);
}
if (!input(pin_b4) && (keyscan==2))
{
write_1621(60,0x02);
}
if (!input(pin_b7) && (keyscan==0))
{
power_prog();
}
if (!input(pin_b7) && (keyscan==1))
{
timer_prog();
}
}

}
}
WHUNG.JOHN
Guest







SORRY MY FRIENDS.THIS POST IS MY CODE CLEARLY.
PostPosted: Sun Sep 09, 2007 5:07 am     Reply with quote

MY FRIENDS MY CODE FOLLOW AS
Code:

#include <16F73.h>
#FUSES NOWDT, XT, NOPUT, NOPROTECT, NOBROWNOUT
#use delay(clock=4000000)
#define DAT PIN_C7
#define WR PIN_B0

#define bias 0x52
#define system 0x02
#define system_dis 0x00
#define lcdon 0x06
#define lcdoff 0x04
#define normal 0xc6

void sendbit_1621(unsigned char data,unsigned char cnt);
void senddatabit_1621(unsigned char data,unsigned char cnt);
void sendcmd(unsigned char command);
void write_1621(unsigned char addr,unsigned char data);
void writeall_1621(unsigned char addr,unsigned char *p,unsigned char cnt );
void all_display(void);
void ht1621_init(void);
void cls(void);
void kk_point(void);
void zero_timer(void);
void first_display(void);
void power_porg(void);
void timer_prog(void);

unsigned int seconds=0,mins=0;
const unsigned int setmins[7]={0,30,25,20,15,10,5};
unsigned timer_key1=0,timer_key2=0;
unsigned int setmins_key=0;
int16 int_count=0;
BYTE plag;
unsigned int keyscan;
unsigned int8 control_motorkey=0;
BYTE power_onoff=0;

const unsigned char timer_c1[2][10]={0x07,0x06,0x03,0x07,0x06,0x05,0x04,0x07,0x07,0x07,0x0D,0x00,0x0E,0x0a,0x03,0x0b,0x0f,0x00,0x0f,0x03};


void sendbit_1621(unsigned char data,unsigned char cnt)
{
unsigned char i;
for (i=0;i<cnt;i++)
{
if ((data&0x80)==0) output_low(DAT);
else output_high(DAT);
output_low(wr);
delay_cycles(1);
output_high(wr);
data<<=1;

}
}

void senddatabit_1621(unsigned char data,unsigned char cnt)
{
unsigned char i;
for (i=0;i<cnt>>=1;

}
}

void sendcmd(unsigned char command)
{
output_low(PIN_c5);
output_low(PIN_c6);

sendbit_1621(0x80,4);
sendbit_1621(command,8);
output_high(wr);

output_high(PIN_c5);
output_high(PIN_c6);



}

void write_1621(unsigned char addr,unsigned char data)
{
output_low(PIN_c5);
output_low(PIN_c6);

sendbit_1621(0xa0,3);
sendbit_1621(addr,6);
senddatabit_1621(data,4);

output_high(PIN_c5);
output_high(PIN_c6);


}

void writeall_1621(unsigned char addr,unsigned char *p,unsigned char cnt )
{
unsigned char i;

output_low(PIN_c5);
output_low(PIN_c6);


sendbit_1621(0xa0,3);
sendbit_1621(addr,6);
for (i=1;i<cnt;i++,p++)
{
senddatabit_1621(*p,8);
}
output_high(PIN_c5);
output_high(PIN_c6);

}

void cls(void)
{
unsigned int j;
for(j=0;j<128;j=j+3)
{
write_1621(j,0x00);
}
}

void all_display(void)
{
unsigned int j;
for(j=0;j<128>0)||(timer_key2>0))
{
if (timer_key1>0)
{
timer_key1=((setmins[setmins_key]-mins)/10);
}
timer_key2=((setmins[setmins_key]-mins)%10);
}


}

}


void ht1621_init(void)
{
sendcmd(bias);
sendcmd(system);
sendcmd(lcdoff);
}

void zero_timer(void)
{
 seconds=0;
 mins=0;
 int_count=0;
 timer_key1=0;
 timer_key2=0;
 
}

void kk_point(void)
{
        if (plag==0)
          {
              //write_1621(44,0x08+timer_c1[0][mins]);
              //write_1621(40,timer_c1[1][mins]); 
              write_1621(36,timer_c1[0][timer_key1]);
              write_1621(32,timer_c1[1][timer_key1]);
              write_1621(44,0x08+timer_c1[0][timer_key2
              write_1621(40,timer_c1[1][timer_key2
              plag=1;
          }
           else
          {
              //write_1621(44,0x00+timer_c1[0][mins]); 
              //write_1621(40,timer_c1[1][mins]);       
              write_1621(36,timer_c1[0][timer_key1]);
              write_1621(32,timer_c1[1][timer_key1]);
              write_1621(44,0X00+timer_c1[0][timer_key2]);
              write_1621(40,timer_c1[1][timer_key2]);//
              plag=0;
          }
}         

void first_display(void)
{
  write_1621(36,timer_c1[0][timer_key1]);
  write_1621(32,timer_c1[1][timer_key1]);
  write_1621(44,timer_c1[0][timer_key2]);/
  write_1621(40,timer_c1[1][timer_key2]);//
}

#int_timer1                     
void timer1_isr(void)
{
      set_timer1(55536);
     
   if(int_count++==100   
       {     
      seconds++;   
      int_count=0;
      kk_point();
    }       
    if (seconds==60)
         {
          mins++; 
          seconds=0;
         
                     if ((timer_key1>0)||(timer_key2>0))
            {
             if (timer_key1>0
             {
               timer_key1=((setmins[setmins_key]-mins)/10);
             }
               timer_key2=((setmins[setmins_key]-mins)%10);
            }
           
           
         }
         
  }


 

void timer_prog(void)
{
if (power_onoff==1)
{
disable_interrupts(INT_timer1);
zero_timer();
enable_interrupts(INT_timer1);
++setmins_key;
timer_key1=(setmins[setmins_key]/10);
timer_key2=(setmins[setmins_key]%10);
write_1621(36,timer_c1[0][timer_key1]);
write_1621(32,timer_c1[1][timer_key1]);
write_1621(44,timer_c1[0][timer_key2]);
write_1621(40,timer_c1[1][timer_key2]);
delay_ms(250);

if (setmins_key==6)
{
setmins_key=0;
}

}

}

void power_prog(void)
{
if (power_onoff==0)
{
sendcmd(lcdon);
first_display();
power_onoff=1;
delay_ms(250);
zero_timer();
setmins_key=0;
enable_interrupts(INT_timer1);
}
else
{
sendcmd(lcdoff);
power_onoff=0;
delay_ms(250);
cls();
disable_interrupts(INT_timer1);
}
}





void main()
{
unsigned int j;
const unsigned int keybord[3][2]= {1,0,
0,1,
1,1};

ht1621_init();
all_display();

for (j=1;j<=3;j++)
{
sendcmd(lcdon);
delay_ms(500);
sendcmd(lcdoff);
delay_ms(500);
}
cls();

setup_timer_1 ( T1_INTERNAL | T1_DIV_BY_1 );
disable_interrupts(INT_timer1
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_timer_2(T2_DISABLED,0,1);
enable_interrupts(GLOBAL);

while(1)
{
for (keyscan=0;keyscan<3;keyscan++)
{
output_bit(PIN_c5,keybord[keyscan][0]);
output_bit(PIN_c6,keybord[keyscan][1]);
if (!input(pin_b1) && (keyscan==2))
{
cls();
}
if (!input(pin_b2) && (keyscan==2))
{
write_1621(60,0x08);
}
if (!input(pin_b3) && (keyscan==2))
{
write_1621(60,0x04);
}
if (!input(pin_b4) && (keyscan==2))
{
write_1621(60,0x02);
}
if (!input(pin_b7) && (keyscan==0))
{
power_prog();
}
if (!input(pin_b7) && (keyscan==1))
{
timer_prog();
}
}

}
}
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Sun Sep 09, 2007 6:33 am     Reply with quote

1) If you become a member of this forum you can edit your posts so you don't have to do a new post everytime you make an error. It will also show more respect to us and tell us you are a serious visitor. This will all help in getting you quicker and better answers.

2) Your post is still messed up because you didn't set the option 'disable HTML in this post'. Example
Code:
for (i=0;i<cnt>>=1;


3) The compiler warning you have is caused by the use of the function write_1621() both inside and outside the interrupt handler. To avoid errors the compiler has added code to disable the interrupts when this function is called. This is one way to solve the problem and you can leave it like that.
whung.john
Guest







thanks u very much
PostPosted: Tue Sep 11, 2007 8:03 am     Reply with quote

Very Happy
my friends. the question is solved.
i find my interrupts re-entrance to other thread.
thank u very much
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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