Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

AT89c4051 problem in using string functions

kirankumarkirankumar Member Posts: 12
Hai,
Iam new to Embedded systems.iam using at89c4051
i have a problem. Problem: P3.3 is connected to a bulb.

and my program is
sbit sw1 P3^3
void main()
{ P3=0xff;
for(i=0;i<10000;i++);
SW1=0;
while(1);
} output; Bulb conneted to p3.3, turned on
this program is working fine.

but when the same main()

void main()
{ int flag;
P3=0xff;
for(i=0;i<10000;i++);

flag=strcmp("INFOLINE","INFOLINE");

if(flag==0)
sw1=0;

while(1);
} when is dumped, its not working,
iam unable to understand, why this is not working.

please assist me in solving this.

Cordially,
Kiran Kumar D

Comments

  • LundinLundin Member Posts: 3,711
    If you don't have a debugger, you should get one. You would likely detect the problem within five minutes.

    Without a debugger, I see nothing wrong with the program, the only safety risk in it is that you are using "int" rather than "signed int". int can either signed or unsigned, it isn't specified by ANSI C but determined by the compiler. Since strcmp() returns a signed int, you will get problems if int is treated as unsigned int.

    Also, where is "i" allocated? Please post the whole code.


    A tip: when writing dummy for-loops, write like this:

    [code]for(i=0; i<10000; i++)
    [b][red];[/red][/b][/code]
    To show that you are explicitly doing nothing, and not that you accidently added a semicolon at the end of the line.
  • stars_625stars_625 Member Posts: 6
    : Hai,
    : Iam new to Embedded systems.iam using at89c4051
    : i have a problem. Problem: P3.3 is connected to a bulb.
    :
    : and my program is
    : sbit sw1 P3^3
    : void main()
    : { P3=0xff;
    : for(i=0;i<10000;i++);
    : SW1=0;
    : while(1);
    : } output; Bulb conneted to p3.3, turned on
    : this program is working fine.
    :
    : but when the same main()
    :
    : void main()
    : { int flag;
    : P3=0xff;
    : for(i=0;i<10000;i++);
    :
    : flag=strcmp("INFOLINE","INFOLINE");
    :
    : if(flag==0)
    : sw1=0;
    :
    : while(1);
    : } when is dumped, its not working,
    : iam unable to understand, why this is not working.
    :
    : please assist me in solving this.
    :
    : Cordially,
    : Kiran Kumar D
    :

    sbit sw1 P3^3 <==> sbit sw1 = P3^3

    sw1 <==> SW1
Sign In or Register to comment.