Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 04, 2016, 04:58:02 04:58


Login with username, password and session length


Pages: [1]
Print
Author Topic: Is there is bug in keil  (Read 1884 times)
0 Members and 1 Guest are viewing this topic.
aamir
Hero Member
*****
 Muted
Offline Offline

Posts: 510

Thank You
-Given: 37
-Receive: 229


« on: May 10, 2010, 11:37:36 11:37 »

I am using keil 9.0 i stuck ith code
#include<reg51.h>
unsigned char Data[8] = {0x02,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
unsigned char  Temp1,Temp2;
unsigned char i,j,k,Mask;
void delay(void);
sbit Clk  =  P3^1  ;
sbit sData =  P3^0  ;
sbit Load  =  P3^2;
        
void main(void)
{                                                                                     
Mask = 0x80;
//SCON =0;                            
//T1 = 0 ;
do
{


for( i = 0;i<8;i++)
{
Temp2 = 1;
if(Temp2 == 1)
{
sData= 1  ;
Clk = 0;
Clk = 1;
}
else
{
sData = 0;
Clk = 0;
Clk = 1;
}

}
}while(1);


}
when i use debugger both if and else stamens are running what is problem


« Last Edit: May 10, 2010, 12:20:00 12:20 by aamir » Logged
Top
Senior Member
****
Offline Offline

Posts: 325

Thank You
-Given: 38
-Receive: 1633


« Reply #1 on: May 10, 2010, 09:03:43 21:03 »

There's no problem it's just the compiler optimizing your code.

Whatever the value of Temp2 you toggle Clk so the compiler has just changed your code; you can see sData=0 is not executed.

Maybe change to:
Code:
if(Temp2 == 1)
{
    sData = 1;
}
else
{
    sData = 0;
}
Clk = 0;
Clk = 1;
Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC