uart string to binary

Status
Not open for further replies.

Varunme

Member
I want to interpret uart string as binary values, i have made a code but not compiling


Code:
void main(){
            char output[7];
int i,rot;
trisb=0x00;
portb=0x00;

UART1_Init(9600);

while(1){

     //  Initialize string with all '\0'
        for(i=0; i<7; i++)
            output[i] = '\0';

        if (!UART1_Data_Ready());        // if there is UART character in buffer
          UART1_Read_Text(output, "m", 255);   // read input from uart

        for(i=0; i<7; i++)
          portb=  output[i] <<1;
}
 
What errors does your compiler tell you? Also post the whole file, not just parts.
 
Last edited:
this is the whole file

I zipped and uploaded the file
 

Attachments

  • UART testing.zip
    7.5 KB · Views: 221
Ok, so your code really is that short. So once again, what errors is your compiler telling you?
 
some syntax errors, but i am not seeing any errors in the code
attached the screenshot
 

Attachments

  • zzztitled-1.jpg
    311.4 KB · Views: 252
The while statement isn't complete there is an end brace missing "}"

C:
void main()
      {
       char output[7];
       int i,rot;
       trisb=0x00;
       portb=0x00;
 
       UART1_Init(9600);

      while(1){

     //  Initialize string with all '\0'
        for(i=0; i<7; i++)
            output[i] = '\0';

        if (!UART1_Data_Ready());        // if there is UART character in buffer
          UART1_Read_Text(output, "m", 255);   // read input from uart

        for(i=0; i<7; i++)
          portb=  output[i] <<1;
      } //<---- HERE
}
 
Also... C is a string friendly language so there are C routines to convert ASCII to binary... atoi().. atof() etc..

They are in the help file..
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…