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

Binary output problem

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



Joined: 21 May 2015
Posts: 181

View user's profile Send private message

Binary output problem
PostPosted: Fri Jan 15, 2016 8:43 pm     Reply with quote

Hai, I would like to send a 16 bit binary string to output B(8bit) and D(8bit). When I send '1111000000110011' why output B and D show '00110011'. I need output B '11110000' and output D'00110011'. How to solve this?

Code:

#include <16F887.h>
 #fuses INTRC_IO, NOWDT
 #use delay(clock=4M)
 #use rs232(baud=9600, UART1, ERRORS)

 #include <stdlib.h>
 #include <input.c>
 #include <string.h>

 int16 binary_string[18];

 //======================
 void main()     
 {
    while (TRUE)
    {
       printf("Enter number:  \n");
       get_string(binary_string,17);
     
       output_B((int8)strtoul(binary_string,0,2));
       output_D((int8)strtoul(binary_string,0,2));

    }
 }
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jan 15, 2016 8:56 pm     Reply with quote

You want a way to get the msb of a 16-bit word. Read about the make8()
function in the CCS manual.
http://www.ccsinfo.com/downloads/ccs_c_manual.pdf
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