huma
Joined: 23 Jun 2006 Posts: 12
|
Please solve my Problem |
Posted: Wed Dec 13, 2006 6:05 am |
|
|
hello,
I m using VC++ to send serial data.
first if 'a' is send then receive next character and put it in count.
similarly
if 'x' is received then receive next chrachers in countR array.
similarly for y.
i want to implement this logic in CCS C .
i want to make it confirm that the code below fulfills this or not.
and i want to create countR, countL arrays of the size of count, how can i do that.
and if the code requires further improments please tell me. i shall be very thankful.
Code: |
#include <16F877.h>
#fuses XT,NOWDT,NOPROTECT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
const int16 states = 10;
int16 countR[states]={0},
countL[states]={0};
int16 i = 0;
char rcvdata, FLAG;
int16 count = 0;
////////////////////////////////////////////
void ReceiveData()
{
while(getc() != 'a'); //if 'a' is received , count = next character i.e some integer
count = getc();
while(getc() != 'x') //if 'x' is received, fill countR with integer
for(i = 0 ; i<= count ;i++)
{
countR[i] = getc();
}
while(getc() != 'y') //if 'y' is received, fill countL with integer
for(i = 0; i <= count; i++)
{
countL[i] = getc();
}
FLAG = TRUE;
}
////////////////////////////////////////////
void main()
{
FLAG = FALSE;
while(true)
{
if(kbhit())
{
ReceiveData();
}
if(FLAG == TRUE)
{
for(i = 0; i < count; i++)
{
//some procesing
}
FLAG = FALSE;
}
}
}
|
|
|
huma
Joined: 23 Jun 2006 Posts: 12
|
|
Posted: Wed Dec 13, 2006 6:12 am |
|
|
I also want to tell that VC++ code first sends
a then
count value then
x followed by a for loop that sends array of integers of size count then
y followed by a for loop that sends array of integers of size of count.
without the use of any delay statements.
Do i need to add delays here in VC code.
and will it send the hex data or decimal means if i send 'a' will it get a in microcontroller or its hex code , similarly for 5.
Please resolve my confusions and tell me, m i going right or wrong.
Thanks. |
|