CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Please solve my Problem

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
huma



Joined: 23 Jun 2006
Posts: 12

View user's profile Send private message

Please solve my Problem
PostPosted: Wed Dec 13, 2006 6:05 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Dec 13, 2006 6:12 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group