hello,
i'm writing modbus code for function 15 in keil using C.In this maximum no. of bytes to be received is 264 & it can be vary from minimum 10 bytes to maximum 264 bytes from user side.
here i have taken one array whose dimension i had taken 264 & each time whn i'm receiving the byte i'm comparing it to either 264 (or null character).after satisfying this condition other part of the program gets executed.this is working fine while debugging the code on keil.
but the probl is that whn i'm executing this code on hardware,then it seems tht microcontroller(AT89C2051) is receiving the data but it is not trnsmiting any thg at all.... The code for this is gvn below
void main()
{
TMOD = 0x20;
SCON = 0x50;
P1 = 0xFF;
DE = 0;
TH1 = 0xFD;
TL1 = 0xFD;
EA = 1;
ES = 1;
TR1 = 1;
while(1)
{
query(); //to receive the character frm user
if(count=='\0')
f = 1;
}
}
void query(void)
{
while(recv_flag)
{
recv_flag = 0;
if(count!='\0')
Recv_Buff[count] = recv;
count++;
}
}
void serial(void) interrupt 4
{
if(RI==1) //if RI interrupt is set to 1
{
RI=0;
DE = 0;
recv=0;
recv = SBUF;
recv_flag=1;
}
else
{
TI = 0; //if TI interrupt is set to 1
DE = 0;
nt++;
if(nt==8)
{
nt = 0;
f = 0;
crcok = 0;
m = 1;
}
if(excep==1)
{
ct++;
if(ct==5)
{
h = 1;
ct = 0;
excep = 0;
f = 0;
m = 1;
}
}
}
}
So,where is the problem i can't able to make out can anyone plz help me out for this..... Although this code is working fine when i have to send the fix no. of bytes.
thanx,
i'm writing modbus code for function 15 in keil using C.In this maximum no. of bytes to be received is 264 & it can be vary from minimum 10 bytes to maximum 264 bytes from user side.
here i have taken one array whose dimension i had taken 264 & each time whn i'm receiving the byte i'm comparing it to either 264 (or null character).after satisfying this condition other part of the program gets executed.this is working fine while debugging the code on keil.
but the probl is that whn i'm executing this code on hardware,then it seems tht microcontroller(AT89C2051) is receiving the data but it is not trnsmiting any thg at all.... The code for this is gvn below
void main()
{
TMOD = 0x20;
SCON = 0x50;
P1 = 0xFF;
DE = 0;
TH1 = 0xFD;
TL1 = 0xFD;
EA = 1;
ES = 1;
TR1 = 1;
while(1)
{
query(); //to receive the character frm user
if(count=='\0')
f = 1;
}
}
void query(void)
{
while(recv_flag)
{
recv_flag = 0;
if(count!='\0')
Recv_Buff[count] = recv;
count++;
}
}
void serial(void) interrupt 4
{
if(RI==1) //if RI interrupt is set to 1
{
RI=0;
DE = 0;
recv=0;
recv = SBUF;
recv_flag=1;
}
else
{
TI = 0; //if TI interrupt is set to 1
DE = 0;
nt++;
if(nt==8)
{
nt = 0;
f = 0;
crcok = 0;
m = 1;
}
if(excep==1)
{
ct++;
if(ct==5)
{
h = 1;
ct = 0;
excep = 0;
f = 0;
m = 1;
}
}
}
}
So,where is the problem i can't able to make out can anyone plz help me out for this..... Although this code is working fine when i have to send the fix no. of bytes.
thanx,