convert ascii to binary

Beta Testing discussion on mikroBasic PRO for AVR.
Post Reply
Author
Message
pfeasma
Posts: 1
Joined: 26 Mar 2011 10:41

convert ascii to binary

#1 Post by pfeasma » 26 Mar 2011 10:46

i want to convert the data received by uart to binary data in the outpout of pic 16F877 but i don't find the fonction is this code is vailable??

Code: Select all

c= Usart_Read();

int asctobin(char c)
{int cv;
int asc[8];
do{ cv=c;
   if  (cv=128){asc[1]=1;
                  cv=cv-128;}
    if (cv>=64){asc[2]=1;
                 cv=cv-64;}
    if (cv>=32){asc[3]=1;
                 cv=cv-32;}
    if (cv>=16){asc[4]=1 ;
                 cv=cv-64;}
    if (cv>=8){asc[5]=1;
                 cv=cv-64;}
    if (cv>=4){asc[6]=1 ;
                 cv=cv-64;}
    if (cv>=2){asc[7]=1;
                 cv=cv-64;}
    if (cv>=1){asc[8]=1;
                 cv=cv-64;}
                 }
  while(cv>0) ;
  return(asc[8]);
  }

User avatar
slavisa.zlatanovic
mikroElektronika team
Posts: 1321
Joined: 07 Apr 2009 09:39

Re: convert ascii to binary

#2 Post by slavisa.zlatanovic » 28 Mar 2011 11:54

Hi!

Please, visit the link below:
http://www.mikroe.com/eng/downloads/get ... obasic.zip

There you'll find the EasyADC Board demo examples.
(Channel 0 to PC example ----> procedure processValue).
I'm sure that you'll find it useful.
Best regards
Slavisa

Post Reply

Return to “mikroBasic PRO for AVR Beta Testing”