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 support@ccsinfo.com

problem porting a keil code to ccs

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



Joined: 17 Nov 2011
Posts: 5

View user's profile Send private message

problem porting a keil code to ccs
PostPosted: Mon Apr 16, 2012 5:31 am     Reply with quote

Hello, I am using the CCS compiler for my project work but I got the SDK for the fingerprint module using Keil which I have no idea of. Can you guys please help me with porting this code ? Thank you.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Mon Apr 16, 2012 6:10 am     Reply with quote

Generally speaking, you can copy the data processing code and need to rewrite the hardware related part. You don't necessarily need to understand the vendor specific Keil (8051 or ARM?) parts, but you should know how serial communication works in CCS (a lot of examples available!) and what your module requires.
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Mon Apr 16, 2012 10:52 am     Reply with quote

Hi,

I noticed that you asked essentially the same question way back in Nov. '11. Have you done any of the conversion yourself, and you're stuck on a few parts, or are you looking for someone to do the whole conversion for you? If the former, post the problem code sections, and if the latter, be prepared to pay $150USD/hour for that work!

Cheers,

John
piero.8010



Joined: 17 Nov 2011
Posts: 5

View user's profile Send private message

the code
PostPosted: Tue Apr 17, 2012 4:31 am     Reply with quote

this is the code that recieves the responds from the module
Its suppose to receive hex values

Code:

#int_rda
char* gethex1() {
 
   int8 ctr;
   char* p;
       for (ctr=0;ctr<4;) {
         temp[ctr++]=getc();
      }
      p = temp;
 //     temp[2]=0;
      printf("Got : %s\n\r",p);
     
 
   return p;
 
}
piero.8010



Joined: 17 Nov 2011
Posts: 5

View user's profile Send private message

PostPosted: Tue Apr 17, 2012 4:36 am     Reply with quote

this is also the code used to send an add command to the module then get response from module.
add command is 0x4d+0x58+0x10+0x03+0x40+0x00+0x00+0xF8

Code:

#include<16F877A.h>
#include<stdlib.h>
#include<string.h>
#include<Command.h>
#use delay(clock = 12000000)
#use rs232(baud=57600,bits=8,parity=N,xmit=pin_C6,rcv=pin_C7,ERRORS)
#fuses HS,NOWDT,NOPROTECT,NOLVP
#include<LCDDRIVER.c>
#include <ctype.h>
//#include<INPUT.c>
#define MAX_BUF_NUMBER 30
#define MAX_LR_NUMBER 30
#define FALSE 0
#define OK 1
#define TIMEOUT 5000

unsigned char  CommBuf[MAX_BUF_NUMBER];
int8 flag;
unsigned char s[6];
unsigned char AddFinger(unsigned char AddrH,unsigned char AddrL,unsigned char OutTime);
unsigned char ReceiveData(unsigned char *p,unsigned char OutTime);
void get_string(char* y, unsigned int8 max);
unsigned char dig;
unsigned char temp[5];
#int_rda
char* gethex1() {
 
   int8 ctr;
   char* p;
       for (ctr=0;ctr<4;) {
         temp[ctr++]=getc();
      }
      p = temp;
 //     temp[2]=0;
      printf("Got : %s\n\r",p);
     
 
   return p;
 
}

void main(){

set_tris_c(0x80);
lcd_init();

enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);


lcd_putc("welcome");

delay_ms(1000);
lcd_putc('\f');
delay_ms(1000);
AddFinger( 0x00,0x00,400 );





}
unsigned char SendCommand(unsigned char BaoBS,unsigned char Number,unsigned char *p)
{       signed int8 j;
        unsigned char i = 0;
        unsigned char  Sum = 0;
        unsigned char a = 0;
       


          if(Number>MAX_LR_NUMBER)
        {
        printf(lcd_putc,"%s","number > maxlrnum");
                return FALSE;//
        }

        //
      //  printf("0x4d");
        putc('M');
   //     a = getc();
        lcd_putc('\f');
       // printf(lcd_putc,"%x",'M');
         
         printf(lcd_putc,"%x",'M');
         delay_ms(1000);
         lcd_putc('\f');
         Sum+= 'M';
         
         printf(lcd_putc,"%x",Sum);
         delay_ms(1000);
         lcd_putc('\f');
      putc  ('X');       
        printf(lcd_putc,"%x",'X');     
        delay_ms(1000);
        lcd_putc('\f');
         Sum+='X';
         printf(lcd_putc,"%x",Sum);
         delay_ms(1000);
         lcd_putc('\f');
        //
       putc (BaoBS);
       printf(lcd_putc,"%x",BaoBS);     
        delay_ms(1000);
        lcd_putc('\f');
        Sum+= BaoBS;
        printf(lcd_putc,"%x",Sum);
         delay_ms(1000);
         lcd_putc('\f');

        //
       putc(Number);
         printf(lcd_putc,"%x",Number);     
        delay_ms(1000);
        lcd_putc('\f');
        Sum += Number;
        printf(lcd_putc,"%x",Sum);
         delay_ms(1000);
         lcd_putc('\f');

        //
        for(i = 0;i<Number;i++)
        {
              putc(*p);
                 printf(lcd_putc,"%x",*p);     
        delay_ms(1000);
        lcd_putc('\f');
                Sum += *p;
                 printf(lcd_putc,"%x",Sum);
         delay_ms(1000);
         lcd_putc('\f');
                p++;
        }

        //
        putc(Sum);
       printf(lcd_putc,"%x",sum);

        //
//get_string(s,30);
//!enable_interrupts(int_rda);
//!enable_interrupts(global);

     i=receivedata(s,5);
     
     printf(lcd_putc,"i = %x",i);
     delay_ms(5000);
//!
        if((OK == i) && (s[4] == C_GET_OK))
        {
        printf(lcd_putc,"%s","sucessful");
        delay_ms(1000);
        lcd_putc('\f');
                return OK;
        }

        if(s[4] == C_GET_FAIL)
        {
        printf(lcd_putc,"%s","failure");
         delay_ms(1000);
        lcd_putc('\f');
                return FALSE;
        }
        if(i == OK) {
             delay_ms(1000);
             lcd_putc('\f');
             printf(lcd_putc, "%s","ok");
       
        }
       
        else {
        delay_ms(1000);
        lcd_putc('\f');
         printf(lcd_putc, "%s","nothing");
        }

       // return TIMEOUT;
}
unsigned char ReceiveData(unsigned char *p,unsigned char OutTime)
{     

        unsigned char Sum = 0;
        unsigned char i = 0;
        unsigned char Number = 0;
         
         
        unsigned char digit[5];
        char* b;
        unsigned char t[5];
 
       
        lcd_putc('\f');
        printf(lcd_putc,"%s","in");
           delay_ms(5000);       
        //
        while(1)
        {
       
        lcd_putc('\f');
        printf(lcd_putc,"%s","in while");
        delay_ms(5000);
                 t=atoi(gethex1());
                 
                           
                   lcd_putc('\f');
                 
                   t = b;
                   printf("b : %s",temp);
                   printf(lcd_putc,"b = %s",temp);
                   delay_ms(5000);
                   lcd_putc('\f');
                       
                        if(t == 'M')
                        {
                                *p = 'M';
                                Sum += *p;
                               
                                p++;
                               
                               printf(lcd_putc,"%s","welcome");
                               
                                break;
                        }
                        else
                        { printf(lcd_putc,"%s","welcomes");
                                return FALSE;//
                        }
               
               
        }
        while(1)
        {
         lcd_putc('\f');
        printf(lcd_putc,"%s","in while");
        delay_ms(5000);
                t=gethex1();
                 
                           
                   lcd_putc('\f');
                 
                   t = b;
                   printf("b : %s",temp);
                   printf(lcd_putc,"b = %s",temp);
                   delay_ms(5000);
                   lcd_putc('\f');
                       
                        printf(lcd_putc,"digit = %x",digit);
                         delay_ms(5000);
                        lcd_putc('\f');
                        //flag = 0;
                        if(digit == 'X')
                        {
                                *p = 'X';
                                Sum += *p;
                               
                                p++;
                               
                                flag = 1;
                                break;
                        }
                        else
                        {
                                return FALSE;//
                        }
               
             
        }

       
        while(1)
        {
               lcd_putc('\f');
        printf(lcd_putc,"%s","in while");
        delay_ms(5000);
                 t=gethex1();
                 
                           
                   lcd_putc('\f');
                 
                   t = b;
                   printf("b : %s",temp);
                   printf(lcd_putc,"b = %s",temp);
                   delay_ms(5000);
                   lcd_putc('\f');
                        printf(lcd_putc,"digit = %x",digit);
                        delay_ms(5000);
                        lcd_putc('\f');
                       
                        //flag = 0;
                        *p = digit;
                        Sum += *p;
                       
                        p++;
                        //
                        flag = 1;
                        break;
               
               
        }

        //
        while(1)
        {
               
                    lcd_putc('\f');
        printf(lcd_putc,"%s","in while");
        delay_ms(5000);
                 t=gethex1();
                 
                           
                   lcd_putc('\f');
                 
                   t = b;
                   printf("b : %s",temp);
                   printf(lcd_putc,"b = %s",temp);
                   delay_ms(5000);
                   lcd_putc('\f');
                        printf(lcd_putc,"digit = %x",digit);
                        delay_ms(5000);
                        lcd_putc('\f');
                       //flag= 0;
                        *p = digit;
                        Sum += *p;
                       
                        Number = *p;
                        p++;
                       
                        flag = 1;
                        break;
                }
               
       

        //
        for(i = 0;i<Number;i++)
        {
                while(1)
                {
                lcd_putc('\f');
        printf(lcd_putc,"%s","in while");
        delay_ms(5000);
                 t=gethex1();
                 
                           
                   lcd_putc('\f');
                 
                   t = b;
                   printf("b : %s",temp);
                   printf(lcd_putc,"b = %s",temp);
                   delay_ms(5000);
                   lcd_putc('\f');
                                 printf(lcd_putc,"digit = %x",digit);
                                delay_ms(5000);
                                 lcd_putc('\f');
                                //flag= 0;
                                *p = digit;
                                Sum += *p;
                               
                               
                                p++;
                             
                                 flag = 1;
                                break;
                        }
                       
               
        }

        //
        while(1)
        {
              lcd_putc('\f');
        printf(lcd_putc,"%s","in while");
        delay_ms(5000);
                 t=gethex1();
                 
                           
                   lcd_putc('\f');
                 
                   t = b;
                   printf("b : %s",temp);
                   printf(lcd_putc,"b = %s",temp);
                   delay_ms(5000);
                   lcd_putc('\f');
                       
                        printf(lcd_putc,"digit = %x",digit);
                        delay_ms(5000);
                        lcd_putc('\f');
                       //flag = 0;
                        *p = digit;
                       
                        printf(lcd_putc,"%x",Sum);
                        delay_ms(5000);
                        lcd_putc('\f');
                        if(Sum == *p)
                        {
                       
                        printf(lcd_putc,"%x",Sum);
                        delay_ms(5000);
                        lcd_putc('\f');
                                return OK;
                        }
                        else
                        {
                           
                           printf(lcd_putc,"%s","sum!=*p");
                            delay_ms(5000);
                           lcd_putc('\f');
                           return FALSE;
                        }
                } 
       
}
unsigned char AddFinger(unsigned char AddrH,unsigned char AddrL,unsigned char OutTime)
{

        unsigned char i = 0;
        CommBuf[0] = C_ADD_FINGER;
        CommBuf[1] = AddrH;
        CommBuf[2] = AddrL;
       // lcd_init();

        i = SendCommand(C_COMMAND,3,CommBuf);//

        if(i != OK)
        {
      //  delay_ms(1000);
        lcd_putc('\f');
        printf(lcd_putc,"%s","i!=OK");
                return FALSE;
        }

        if(OK == ReceiveData(CommBuf,OutTime))
        {
                if((C_ANSWER == CommBuf[2])&&(0x02 == CommBuf[3])&&(C_ADD_FINGER == CommBuf[4]))
                {
                        //
                        if(ANSWER_OK == CommBuf[5])
                        {
                           printf(   lcd_putc,"%s","answwer=commbuf");  //
//!                                BellOn();
//!                                BellTimer = 6;//
                        }
                        else
                        {
                        printf( lcd_putc,"%s","answwer!=commbuf");
                                return CommBuf[5];//
                        }
                }
                else
                {
                printf(lcd_putc,"%s","command not correct");
                        return FALSE;
                }               
        }
        else
        {
                return FALSE;
        }

        if(OK == ReceiveData(CommBuf,OutTime))
        {
                if((C_ANSWER == CommBuf[2])&&(0x02 == CommBuf[3])&&(C_ADD_FINGER == CommBuf[4]))
                {
                        printf(lcd_putc,"%s","command right");
                        return CommBuf[5];//
                }
                else
                {
                printf(lcd_putc,"%s","command false");
                        return FALSE;
                }               
        }
        else
        {
        printf(lcd_putc,"%s","receivedata not right");
                return FALSE;
        }
}
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Tue Apr 17, 2012 9:31 am     Reply with quote

Hi,

Hmmm, that code is in pretty bad shape, and is going to need lots of work to make it right. Just to clarify, is this a real hardware effort, or a software simulation like Proteus?

If it's real hardware, what platform are you using? Did you buy it, or make it yourself? Can you do simple stuff with it like blinking an LED?

If you have any hope of getting this project done, you need to post a link to the fingerprint module, and post a verbal description of what the software is supposed to be doing (eg. "the code is supposed to loop waiting for a fingerprint swipe, and then it is supposed to display the ID of the individual on the LCD display").

Right up front, I'll warn you that you have probably bitten off more than you can chew with this project given your level of coding skill. However, if you show some initiative, we can probably help you.....

John
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Tue Apr 17, 2012 10:15 am     Reply with quote

To refer to one basic point, you obviously misunderstood the purpose and and requirements of an UART receive interrupt function.

An interrupt function is expected to receive a single character and writes it to a circular buffer, then resumes the regular code execution.

It must never be called from the regular code and won't return a value. It shouldn't wait for more characters to arrive or other events and not perform lengthy delay or multi character print operations. You can refer to the CCS example EX_SISR.C to get the basic idea.

I don't believe, that the respective code part has been ported from a working 8051 application.
piero.8010



Joined: 17 Nov 2011
Posts: 5

View user's profile Send private message

PostPosted: Wed Apr 18, 2012 2:30 pm     Reply with quote

Pls this is the link to the fingerprint module.
http://robokits.co.in/shop/index.php?main_page=advanced_search_result&search_in_description=1&keyword=sm630

The device is suppose to be to add fingerprints to its database, delete fingerprint and search for fingerprints.

I followed your advice and made some changes to my code by its stil not giving me any response.

I am building the hardware myself.

This is my new code its stil not working. Pls help me its my final year project. Need to submit it very soon. Thank you
Code:

#include<16F877.h>
#include<stdlib.h>
#include<string.h>
#include<Command.h>

#use delay(clock = 12000000)
#use rs232(baud=57600,bits=8,parity=N,xmit=pin_C6,rcv=pin_C7,ERRORS)
#fuses HS,NOWDT,NOPROTECT,NOLVP

#include<LCDDRIVER.c>
#include <ctype.h>
#include<TONES.c>
//#include<INPUT.c>

#define MAX_BUF_NUMBER 30
#define MAX_LR_NUMBER 30
#define FALSE 0
#define OK 1
#define TIMEOUT 5000

unsigned char  CommBuf[MAX_BUF_NUMBER];
unsigned char s[6];
unsigned char SendCommand(unsigned char BaoBS,unsigned char Number,unsigned char *p);

unsigned char AddFinger(unsigned char AddrH,unsigned char AddrL,unsigned char OutTime);
unsigned char ReceiveData(unsigned char *p,unsigned char OutTime);
void get_string(char* y, unsigned int8 max);

#int_rda
#define BUFFER_SIZE 4
BYTE sbuf[BUFFER_SIZE];
BYTE next_in = 0;
BYTE next_out = 0;


#int_rda
void serial_isr() {
   int t;

   sbuf[next_in]=getc();
   t=next_in;
   next_in=(next_in+1) % BUFFER_SIZE;
   if(next_in==next_out)
     next_in=t;           // Buffer full !!
}

#define bkbhit (next_in!=next_out)

BYTE bgetc() {
   BYTE c;

   while(!bkbhit) ;
   c=sbuf[next_out];
   next_out=(next_out+1) % BUFFER_SIZE;
   return(c);
}

void main(){

set_tris_c(0x80);
lcd_init();

enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);

lcd_putc("welcome");

delay_ms(1000);
lcd_putc('\f');
delay_ms(1000);
AddFinger( 0x00,0x00,400 );
}

unsigned char SendCommand(unsigned char BaoBS,unsigned char Number,unsigned char *p)
{       
        unsigned char i = 0;
        unsigned char  Sum = 0;

          if(Number>MAX_LR_NUMBER)
        {
        printf(lcd_putc,"%s","number > maxlrnum");
                return FALSE;//
        }

        putc('M');
   
         Sum+= 'M';
         
         
      putc  ('X');       
       
         Sum+='X';
         
       putc (C_COMMAND);
     
        Sum+= BaoBS;

        //
       putc(Number);
         
        Sum += Number;
       
        //
        for(i = 0;i<Number;i++)
        {
              putc( *p);
             
                Sum += *p;
               
                p++;
        }
        //
        putc(Sum);
 
     i=receivedata(s,5);
 
//!
        if((OK == i) && (s[4] == C_GET_OK))
        {
                return OK;
        }

        if(s[4] == C_GET_FAIL)
        {
                return FALSE;
        }
       
             // return TIMEOUT;
}

unsigned char ReceiveData(unsigned char *p,unsigned char OutTime)
{     
        unsigned char Sum = 0;
        unsigned char i = 0;
        unsigned char Number = 0;
       
        while(1)
        {
                 while(bkbhit)
                 putc(bgetc());
             if(SBUF == 'M'){
                       
                                Sum += *p;
                                p++;
                           //     Timer = 2;//
                                break;
                        }
                        else
                        {
                                return FALSE;//
                        }
        }
        while(1)
        {
                        while(bkbhit)
                        if(SBUF == 'X')
                        {
                                *p = 'X';
                                Sum += *p;
                                p++;
                              //  Timer = 2;//
                                break;
                        }
                        else
                        {
                                return FALSE;//
                        }
        }

        while(1)
        {
          while(bkbhit)
                        *p = SBUF;
                        Sum += *p;
                        p++;
               
                        break;
        }

        //
        while(1)
        {
                while(bkbhit)
                *p = SBUF;
                        Sum += *p;
                        Number = *p;
                        p++;
                       
                     break;
          }

        //
        for(i = 0;i<Number;i++)
        {
                while(1)
                {
                               while(bkbhit)
                                *p = SBUF;
                                Sum += *p;
                                p++;
                               
                                break;
                        }
                       
               
        }

        //
        while(1)
        {              while(bkbhit)
                       *p = SBUF;
                        if(Sum == *p)
                        {
                                return OK;
                        }
                        return FALSE;
                } 
       
}

unsigned char AddFinger(unsigned char AddrH,unsigned char AddrL,unsigned char OutTime)
{
        unsigned char i = 0;
        CommBuf[0] = C_ADD_FINGER;
        CommBuf[1] = AddrH;
        CommBuf[2] = AddrL;
       // lcd_init();

        i = SendCommand(C_COMMAND,3,CommBuf);//

        if(i != OK)
        {
      //  delay_ms(1000);
        lcd_putc('\f');
        printf(lcd_putc,"%s","i!=OK");
                return FALSE;
        }

        if(OK == ReceiveData(CommBuf,OutTime))
        {
                if((C_ANSWER == CommBuf[2])&&(0x02 == CommBuf[3])&&(C_ADD_FINGER == CommBuf[4]))
                {
                        //
                        if(ANSWER_OK == CommBuf[5])
                        {
                          generate_tone(D_NOTE[3], 500);
 // Delay_ms(50);output_high(pin_d3);
                         //elay_ms(1000);
                         //utput_low(pin_d3);
                        }
                        else
                        {
                        printf( lcd_putc,"%s","answwer!=commbuf");
                                return CommBuf[5];//
                        }
                }
                else
                {
                printf(lcd_putc,"%s","command not correct");
                        return FALSE;
                }               
        }
        else
        {
                return FALSE;
        }

        if(OK == ReceiveData(CommBuf,OutTime))
        {
                if((C_ANSWER == CommBuf[2])&&(0x02 == CommBuf[3])&&(C_ADD_FINGER == CommBuf[4]))
                {
                        printf(lcd_putc,"%s","command right");
                        return CommBuf[5];//
                }
                else
                {
                printf(lcd_putc,"%s","command false");
                        return FALSE;
                }               
        }
        else
        {
        printf(lcd_putc,"%s","receivedata not right");
                return FALSE;
        }
}
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Thu Apr 19, 2012 3:07 pm     Reply with quote

Hi Piero,

Hmmm, you aren't doing yourself (or us!) any favors with this strategy! Dumping a large block of code on us, and saying "it doesn't work" is not really good-practice troubleshooting, or how the forum is supposed to work! We are not here to debug an entire project for you, but to help with roadblocks along the way to you completing the project by yourself!

You really need to break your project down into more manageable chunks. For example, is the PIC actually running? Can you blink an LED at a predictable rate/duration? Can you send a packet of data to the fingerprint module, and does it return the expected data? Until you get this basic functionality working then there is no point in jumping into all the other stuff in your code. You need to achieve some early successes in your troubleshooting, and then build on those successes until the project is complete.

Thanks,

John
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Thu Apr 19, 2012 11:25 pm     Reply with quote

I can confirm, that your code is now basically implementing a correct UART communication. I have to say basically, because there may be still detail errors that cause it to fail. A special point are the fingerprint module interface and it's communications requirements. I briefly reviewed the datasheet and didn't find an obvious problem.

Now you need to test and debug your code stepwise. It starts with the points mentioned by ezflyr: Is the processor running at all (should be obvious from the LCD display operation), does it send serial data with correct baud rate? If you don't achieve quick success in module communication, which can happen on a lucky day, you need a means to debug the communication, e.g. checking the waveform with an oscilloscope or with a sniffer software, using correct conversion from TTL to RS232 level, etc. This will take probably some days, depending on your skill and available tools. You should be aware of possible hardware errors (mixed up wires, whatsoever), datasheet errata and a large variation of possible bugs in your code.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Fri Apr 20, 2012 2:36 pm     Reply with quote

I only had a quick glance at the code but noticed a few things:
Code:
#int_rda
#define BUFFER_SIZE 4
BYTE sbuf[BUFFER_SIZE];
BYTE next_in = 0;
BYTE next_out = 0;


#int_rda
void serial_isr() {
Remove the first #int_rda line, it is an error. I'm surprised the compiler doesn't complain.

Code:
          while(bkbhit)
                        *p = SBUF;
                        Sum += *p;
                        p++;
This doesn't look correct. In C only the first command after the while instruction is executed, if you want to execute multiple commands you have to put them into a '{}' -block like:
Code:
          while(bkbhit)
          {
                        *p = SBUF;
                        Sum += *p;
                        p++;
          }
This problem is everywhere in your code where you do while(bkbhit), i.e. about 6 times.

This is an ugly code construct:
Code:
        while(1)
        {
          while(bkbhit)
                        *p = SBUF;
                        Sum += *p;
                        p++;
               
                        break;
        }
I've no clue as to what you are trying to do here, but I'm quiet sure this code is not doing what you want it to do. Anyway, the combination of two while loops inside each other and a break looks ugly. The while(1) is unconditional, it would be easier to understand the intention of your code when you add a test condition and then remove the break condition.

Code:
printf( lcd_putc,"%s","answwer!=commbuf");
This code is working, but inefficient. It shows you don't understand the printf command very well. You can get the same result by removing the %s:
Code:
printf( lcd_putc, "answer!=commbuf");
Can be fixed in about 5 locations.

Code:
BYTE sbuf[BUFFER_SIZE];
...
if(SBUF == 'M'){
First of all, please be consistent in capitalization of variables. The CCS compiler doesn't mind but all official ANSI C compilers do.
Second, this code will never work as sbuf is a _pointer_. To read the contents of sbuf you would need a construct like *sbuf, or sbuf[0].

Being curious to the origin of these coding errors I tried the link you provided but the link doesn't work or the site is down. Trying to surf to www.robokits.co.in failed too.
I did find several other Indian students working on a similar project. You are all in the same class?

Well, it looks like you were trying to make a shortcut by converting an existing program but looking at the quality of the code you have produced this far I'm afraid this is going to be a long running assignment...
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