Hi,
I am using BL1800 and trying to send and receive serial data on port D. Although
I have been successful in sending serial data through Port D, I can't
receive any sort of data on it. I have painstakingly verified that the bytes
coming back from the external device is making back all the way to the
processor, but I simply can't capture the bytes in my code. Every time I
read, it returns with all zeros. Also, from looking at the schematic for the
processor, I found out that PC0 is for sending and PC1 is for receiving serial
data on Port D (correct me if I am wrong).
This is how I am writing:
Jr485Tx();
delay(10);
serDwrite(&PortAdxout[0],6);
while(BitRdPortI(SDSR,SS_TFULL_BIT) != 0);
while(BitRdPortI(SDSR,SS_TPRG_BIT) == 1);
This is how I am reading:
t=MS_TIMER;
Jr485Rx();
delay(10);
while(serDpeek()==-1)
{
if (MS_TIMER>(t+100))
break;
}
myret=serDread(&PortAdxin[0],5,100);
So, what am I doing wrong? The funny thing is all this was working before and
last couple of days I was making some changes in the code. From then on, it
never worked even when I compiled and uploaded the original working code.
BL1800 Port D serial communication issue.
Started by ●January 18, 2012
Reply by ●January 24, 20122012-01-24
Just as a first pass, this is my old code from 2004 that worked:
Jr485Init() // needed first and once only.
CommWrite() first, followed by comm read snippet at the end.
nodebug BOOL CommWrite1810(char *Command, int Count)
{
BOOL CWrite;
serDwrFlush(); // Clear Rx and Tx data buffers
serDrdFlush();
Jr485Tx(); // Enable transmitter
CWrite = serDwrite(Command, Count);
while(serDwrUsed() > 0); // Wait for bytes to be output
MyDelay(m_MyDelay);
while(serDrdUsed() > 0)
serDgetc(); // Flush echoed bytes
Jr485Rx(); // Disable transmitter
return(CWrite == Count);
}
// Read extract:
for(Limit = MS_TIMER + TimeOut; MS_TIMER < Limit; )
{
n = serDread(RBuf, ExpectedLength, TimeOut);
if(n > 0)
return n;
}
--- In r..., "TN" wrote:
>
> Hi,
>
> I am using BL1800 and trying to send and receive serial data on port D. Although I have been successful in sending serial data through Port D, I can't receive any sort of data on it. I have painstakingly verified that the bytes coming back from the external device is making back all the way to the processor, but I simply can't capture the bytes in my code. Every time I read, it returns with all zeros. Also, from looking at the schematic for the processor, I found out that PC0 is for sending and PC1 is for receiving serial data on Port D (correct me if I am wrong).
>
> This is how I am writing:
>
> Jr485Tx();
>
> delay(10);
>
> serDwrite(&PortAdxout[0],6);
>
> while(BitRdPortI(SDSR,SS_TFULL_BIT) != 0);
> while(BitRdPortI(SDSR,SS_TPRG_BIT) == 1);
>
> This is how I am reading:
>
> t=MS_TIMER;
> Jr485Rx();
> delay(10);
>
> while(serDpeek()==-1)
> {
> if (MS_TIMER>(t+100))
> break;
> }
>
> myret=serDread(&PortAdxin[0],5,100);
>
> So, what am I doing wrong? The funny thing is all this was working before and last couple of days I was making some changes in the code. From then on, it never worked even when I compiled and uploaded the original working code.
>
Jr485Init() // needed first and once only.
CommWrite() first, followed by comm read snippet at the end.
nodebug BOOL CommWrite1810(char *Command, int Count)
{
BOOL CWrite;
serDwrFlush(); // Clear Rx and Tx data buffers
serDrdFlush();
Jr485Tx(); // Enable transmitter
CWrite = serDwrite(Command, Count);
while(serDwrUsed() > 0); // Wait for bytes to be output
MyDelay(m_MyDelay);
while(serDrdUsed() > 0)
serDgetc(); // Flush echoed bytes
Jr485Rx(); // Disable transmitter
return(CWrite == Count);
}
// Read extract:
for(Limit = MS_TIMER + TimeOut; MS_TIMER < Limit; )
{
n = serDread(RBuf, ExpectedLength, TimeOut);
if(n > 0)
return n;
}
--- In r..., "TN" wrote:
>
> Hi,
>
> I am using BL1800 and trying to send and receive serial data on port D. Although I have been successful in sending serial data through Port D, I can't receive any sort of data on it. I have painstakingly verified that the bytes coming back from the external device is making back all the way to the processor, but I simply can't capture the bytes in my code. Every time I read, it returns with all zeros. Also, from looking at the schematic for the processor, I found out that PC0 is for sending and PC1 is for receiving serial data on Port D (correct me if I am wrong).
>
> This is how I am writing:
>
> Jr485Tx();
>
> delay(10);
>
> serDwrite(&PortAdxout[0],6);
>
> while(BitRdPortI(SDSR,SS_TFULL_BIT) != 0);
> while(BitRdPortI(SDSR,SS_TPRG_BIT) == 1);
>
> This is how I am reading:
>
> t=MS_TIMER;
> Jr485Rx();
> delay(10);
>
> while(serDpeek()==-1)
> {
> if (MS_TIMER>(t+100))
> break;
> }
>
> myret=serDread(&PortAdxin[0],5,100);
>
> So, what am I doing wrong? The funny thing is all this was working before and last couple of days I was making some changes in the code. From then on, it never worked even when I compiled and uploaded the original working code.
>