Bit manipulation, ascii with binary
How does one apply bit manipulation (AND clear, OR set and perhaps XOR to examine) to each bit in a binary? What I would like to do is input a character or string and output the message in binary to a specific output pin on my MCU. I want to use bit manipulation because creating a function for each character on the ascii table would take lots of memory on my MCU.
How is see so far is that I have set the pin output and declared each bit as a variable. Does this make sense so far?
void bits (void)
{
#define RSTEST PORTBbits.RB5 //Declaring the port for serial
#define RSOUT TRISBbits.RB5 = 0 //Sets the port RB5 as an output
unsigned int b0 = 0 ; // Binary 00000000
unsigned int b1 = 0 ;
unsigned int b2 = 0 ;
unsigned int b3 = 0 ;
unsigned int b4 = 0 ;
unsigned int b5 = 0 ;
unsigned int b6 = 0 ;
unsigned int b7 = 0 ;
}
The reason I am trying to do this is because writing a function for each ASCII code is long and uncessary memory space.
void main(void)
{
while (1)
{
RSTEST ; // same config as above
// RSOUT = 1 ; // MSB
// __delay_ms(10);
// RSOUT = 0 ; // START
// __delay_us(25);
// RSOUT = 0 ; // 1
// __delay_us(25);
// RSOUT = 1 ; // 2
// __delay_us(25);
// RSOUT = 0 ; // 3
// __delay_us(25);
// RSOUT = 1 ; // 4
// __delay_us(25);
// RSOUT = 0 ; // 5
// __delay_us(25);
// RSOUT = 0 ; // 6
// __delay_us(25);
// RSOUT = 1 ; // 7
// __delay_us(25);
// RSOUT = 0 ; // 8
// __delay_us(25);
// RSOUT = 1 ; // STOP
//
// RSOUT = 1 ; // MSB
// __delay_ms(10);
// RSOUT = 0 ; // START
// __delay_us(25);
// RSOUT = 0 ; // 1
// __delay_us(25);
// RSOUT = 0 ; // 2
// __delay_us(25);
// RSOUT = 0 ; // 3
// __delay_us(25);
// RSOUT = 0 ; // 4
// __delay_us(25);
// RSOUT = 1 ; // 5
// __delay_us(25);
// RSOUT = 1 ; // 6
// __delay_us(25);
// RSOUT = 0 ; // 7
// __delay_us(25);
// RSOUT = 0 ; // 8
// __delay_us(25);
// RSOUT = 1 ; // STOP
//
// RSOUT = 1 ; // MSB
// __delay_ms(10);
// RSOUT = 0 ; // START
// __delay_us(25);
// RSOUT = 1 ; // 1
// __delay_us(25);
// RSOUT = 0 ; // 2
// __delay_us(25);
// RSOUT = 1 ; // 3
// __delay_us(25);
// RSOUT = 0 ; // 4
// __delay_us(25);
// RSOUT = 0 ; // 5
// __delay_us(25);
// RSOUT = 0 ; // 6
// __delay_us(25);
// RSOUT = 1 ; // 7
// __delay_us(25);
// RSOUT = 0 ; // 8
// __delay_us(25);
// RSOUT = 1 ; // STOP
}
}
All those lines just to print JOE.
Can I just something similar to printf("JOE");
I do not want to use Tx and Rx Hardware EUSART but Software EUSART.
c pic
add a comment |
How does one apply bit manipulation (AND clear, OR set and perhaps XOR to examine) to each bit in a binary? What I would like to do is input a character or string and output the message in binary to a specific output pin on my MCU. I want to use bit manipulation because creating a function for each character on the ascii table would take lots of memory on my MCU.
How is see so far is that I have set the pin output and declared each bit as a variable. Does this make sense so far?
void bits (void)
{
#define RSTEST PORTBbits.RB5 //Declaring the port for serial
#define RSOUT TRISBbits.RB5 = 0 //Sets the port RB5 as an output
unsigned int b0 = 0 ; // Binary 00000000
unsigned int b1 = 0 ;
unsigned int b2 = 0 ;
unsigned int b3 = 0 ;
unsigned int b4 = 0 ;
unsigned int b5 = 0 ;
unsigned int b6 = 0 ;
unsigned int b7 = 0 ;
}
The reason I am trying to do this is because writing a function for each ASCII code is long and uncessary memory space.
void main(void)
{
while (1)
{
RSTEST ; // same config as above
// RSOUT = 1 ; // MSB
// __delay_ms(10);
// RSOUT = 0 ; // START
// __delay_us(25);
// RSOUT = 0 ; // 1
// __delay_us(25);
// RSOUT = 1 ; // 2
// __delay_us(25);
// RSOUT = 0 ; // 3
// __delay_us(25);
// RSOUT = 1 ; // 4
// __delay_us(25);
// RSOUT = 0 ; // 5
// __delay_us(25);
// RSOUT = 0 ; // 6
// __delay_us(25);
// RSOUT = 1 ; // 7
// __delay_us(25);
// RSOUT = 0 ; // 8
// __delay_us(25);
// RSOUT = 1 ; // STOP
//
// RSOUT = 1 ; // MSB
// __delay_ms(10);
// RSOUT = 0 ; // START
// __delay_us(25);
// RSOUT = 0 ; // 1
// __delay_us(25);
// RSOUT = 0 ; // 2
// __delay_us(25);
// RSOUT = 0 ; // 3
// __delay_us(25);
// RSOUT = 0 ; // 4
// __delay_us(25);
// RSOUT = 1 ; // 5
// __delay_us(25);
// RSOUT = 1 ; // 6
// __delay_us(25);
// RSOUT = 0 ; // 7
// __delay_us(25);
// RSOUT = 0 ; // 8
// __delay_us(25);
// RSOUT = 1 ; // STOP
//
// RSOUT = 1 ; // MSB
// __delay_ms(10);
// RSOUT = 0 ; // START
// __delay_us(25);
// RSOUT = 1 ; // 1
// __delay_us(25);
// RSOUT = 0 ; // 2
// __delay_us(25);
// RSOUT = 1 ; // 3
// __delay_us(25);
// RSOUT = 0 ; // 4
// __delay_us(25);
// RSOUT = 0 ; // 5
// __delay_us(25);
// RSOUT = 0 ; // 6
// __delay_us(25);
// RSOUT = 1 ; // 7
// __delay_us(25);
// RSOUT = 0 ; // 8
// __delay_us(25);
// RSOUT = 1 ; // STOP
}
}
All those lines just to print JOE.
Can I just something similar to printf("JOE");
I do not want to use Tx and Rx Hardware EUSART but Software EUSART.
c pic
Use>>=shift to iterate over bits.while (val) { output(val & 1); val >>= 1; }
– Kamil Cuk
Nov 15 '18 at 14:55
How do you mean?
– M2T156
Nov 15 '18 at 15:18
Why don't use the hardware UART? A lott of PIC will support it.
– Mike
Nov 16 '18 at 6:41
Because I want to experiment with software UART.
– M2T156
Nov 16 '18 at 7:36
add a comment |
How does one apply bit manipulation (AND clear, OR set and perhaps XOR to examine) to each bit in a binary? What I would like to do is input a character or string and output the message in binary to a specific output pin on my MCU. I want to use bit manipulation because creating a function for each character on the ascii table would take lots of memory on my MCU.
How is see so far is that I have set the pin output and declared each bit as a variable. Does this make sense so far?
void bits (void)
{
#define RSTEST PORTBbits.RB5 //Declaring the port for serial
#define RSOUT TRISBbits.RB5 = 0 //Sets the port RB5 as an output
unsigned int b0 = 0 ; // Binary 00000000
unsigned int b1 = 0 ;
unsigned int b2 = 0 ;
unsigned int b3 = 0 ;
unsigned int b4 = 0 ;
unsigned int b5 = 0 ;
unsigned int b6 = 0 ;
unsigned int b7 = 0 ;
}
The reason I am trying to do this is because writing a function for each ASCII code is long and uncessary memory space.
void main(void)
{
while (1)
{
RSTEST ; // same config as above
// RSOUT = 1 ; // MSB
// __delay_ms(10);
// RSOUT = 0 ; // START
// __delay_us(25);
// RSOUT = 0 ; // 1
// __delay_us(25);
// RSOUT = 1 ; // 2
// __delay_us(25);
// RSOUT = 0 ; // 3
// __delay_us(25);
// RSOUT = 1 ; // 4
// __delay_us(25);
// RSOUT = 0 ; // 5
// __delay_us(25);
// RSOUT = 0 ; // 6
// __delay_us(25);
// RSOUT = 1 ; // 7
// __delay_us(25);
// RSOUT = 0 ; // 8
// __delay_us(25);
// RSOUT = 1 ; // STOP
//
// RSOUT = 1 ; // MSB
// __delay_ms(10);
// RSOUT = 0 ; // START
// __delay_us(25);
// RSOUT = 0 ; // 1
// __delay_us(25);
// RSOUT = 0 ; // 2
// __delay_us(25);
// RSOUT = 0 ; // 3
// __delay_us(25);
// RSOUT = 0 ; // 4
// __delay_us(25);
// RSOUT = 1 ; // 5
// __delay_us(25);
// RSOUT = 1 ; // 6
// __delay_us(25);
// RSOUT = 0 ; // 7
// __delay_us(25);
// RSOUT = 0 ; // 8
// __delay_us(25);
// RSOUT = 1 ; // STOP
//
// RSOUT = 1 ; // MSB
// __delay_ms(10);
// RSOUT = 0 ; // START
// __delay_us(25);
// RSOUT = 1 ; // 1
// __delay_us(25);
// RSOUT = 0 ; // 2
// __delay_us(25);
// RSOUT = 1 ; // 3
// __delay_us(25);
// RSOUT = 0 ; // 4
// __delay_us(25);
// RSOUT = 0 ; // 5
// __delay_us(25);
// RSOUT = 0 ; // 6
// __delay_us(25);
// RSOUT = 1 ; // 7
// __delay_us(25);
// RSOUT = 0 ; // 8
// __delay_us(25);
// RSOUT = 1 ; // STOP
}
}
All those lines just to print JOE.
Can I just something similar to printf("JOE");
I do not want to use Tx and Rx Hardware EUSART but Software EUSART.
c pic
How does one apply bit manipulation (AND clear, OR set and perhaps XOR to examine) to each bit in a binary? What I would like to do is input a character or string and output the message in binary to a specific output pin on my MCU. I want to use bit manipulation because creating a function for each character on the ascii table would take lots of memory on my MCU.
How is see so far is that I have set the pin output and declared each bit as a variable. Does this make sense so far?
void bits (void)
{
#define RSTEST PORTBbits.RB5 //Declaring the port for serial
#define RSOUT TRISBbits.RB5 = 0 //Sets the port RB5 as an output
unsigned int b0 = 0 ; // Binary 00000000
unsigned int b1 = 0 ;
unsigned int b2 = 0 ;
unsigned int b3 = 0 ;
unsigned int b4 = 0 ;
unsigned int b5 = 0 ;
unsigned int b6 = 0 ;
unsigned int b7 = 0 ;
}
The reason I am trying to do this is because writing a function for each ASCII code is long and uncessary memory space.
void main(void)
{
while (1)
{
RSTEST ; // same config as above
// RSOUT = 1 ; // MSB
// __delay_ms(10);
// RSOUT = 0 ; // START
// __delay_us(25);
// RSOUT = 0 ; // 1
// __delay_us(25);
// RSOUT = 1 ; // 2
// __delay_us(25);
// RSOUT = 0 ; // 3
// __delay_us(25);
// RSOUT = 1 ; // 4
// __delay_us(25);
// RSOUT = 0 ; // 5
// __delay_us(25);
// RSOUT = 0 ; // 6
// __delay_us(25);
// RSOUT = 1 ; // 7
// __delay_us(25);
// RSOUT = 0 ; // 8
// __delay_us(25);
// RSOUT = 1 ; // STOP
//
// RSOUT = 1 ; // MSB
// __delay_ms(10);
// RSOUT = 0 ; // START
// __delay_us(25);
// RSOUT = 0 ; // 1
// __delay_us(25);
// RSOUT = 0 ; // 2
// __delay_us(25);
// RSOUT = 0 ; // 3
// __delay_us(25);
// RSOUT = 0 ; // 4
// __delay_us(25);
// RSOUT = 1 ; // 5
// __delay_us(25);
// RSOUT = 1 ; // 6
// __delay_us(25);
// RSOUT = 0 ; // 7
// __delay_us(25);
// RSOUT = 0 ; // 8
// __delay_us(25);
// RSOUT = 1 ; // STOP
//
// RSOUT = 1 ; // MSB
// __delay_ms(10);
// RSOUT = 0 ; // START
// __delay_us(25);
// RSOUT = 1 ; // 1
// __delay_us(25);
// RSOUT = 0 ; // 2
// __delay_us(25);
// RSOUT = 1 ; // 3
// __delay_us(25);
// RSOUT = 0 ; // 4
// __delay_us(25);
// RSOUT = 0 ; // 5
// __delay_us(25);
// RSOUT = 0 ; // 6
// __delay_us(25);
// RSOUT = 1 ; // 7
// __delay_us(25);
// RSOUT = 0 ; // 8
// __delay_us(25);
// RSOUT = 1 ; // STOP
}
}
All those lines just to print JOE.
Can I just something similar to printf("JOE");
I do not want to use Tx and Rx Hardware EUSART but Software EUSART.
c pic
c pic
asked Nov 15 '18 at 14:52
M2T156M2T156
215
215
Use>>=shift to iterate over bits.while (val) { output(val & 1); val >>= 1; }
– Kamil Cuk
Nov 15 '18 at 14:55
How do you mean?
– M2T156
Nov 15 '18 at 15:18
Why don't use the hardware UART? A lott of PIC will support it.
– Mike
Nov 16 '18 at 6:41
Because I want to experiment with software UART.
– M2T156
Nov 16 '18 at 7:36
add a comment |
Use>>=shift to iterate over bits.while (val) { output(val & 1); val >>= 1; }
– Kamil Cuk
Nov 15 '18 at 14:55
How do you mean?
– M2T156
Nov 15 '18 at 15:18
Why don't use the hardware UART? A lott of PIC will support it.
– Mike
Nov 16 '18 at 6:41
Because I want to experiment with software UART.
– M2T156
Nov 16 '18 at 7:36
Use
>>= shift to iterate over bits. while (val) { output(val & 1); val >>= 1; }– Kamil Cuk
Nov 15 '18 at 14:55
Use
>>= shift to iterate over bits. while (val) { output(val & 1); val >>= 1; }– Kamil Cuk
Nov 15 '18 at 14:55
How do you mean?
– M2T156
Nov 15 '18 at 15:18
How do you mean?
– M2T156
Nov 15 '18 at 15:18
Why don't use the hardware UART? A lott of PIC will support it.
– Mike
Nov 16 '18 at 6:41
Why don't use the hardware UART? A lott of PIC will support it.
– Mike
Nov 16 '18 at 6:41
Because I want to experiment with software UART.
– M2T156
Nov 16 '18 at 7:36
Because I want to experiment with software UART.
– M2T156
Nov 16 '18 at 7:36
add a comment |
1 Answer
1
active
oldest
votes
I think you need a function like this, using MSB first:
#define MSB 1
#define LSB 0
void out_char(char character, char bit_order){
uint8_t i = 0;
RSOUT = 1 ; // MSB
__delay_ms(10);
RSOUT = 0 ; // START
__delay_us(25);
for (i = 8; i>0; --i){
if (bit_order){
RSOUT = (character & 0x80) ? 1:0;
character <<= 1;
} else {
RSOUT = (character & 0x01);
character >>= 1;
}
__delay_us(25);
}
RSOUT = 1 ; // STOP
}
void out_str(char * string, uint8_t len, char bit_order){
uint8_t i = 0;
for (i = 0; i< len; i++){
out_char(string[i], bit_order);
}
}
out_str("Hello world",11, MSB); // 'H' 0x48 will be '0-1-0-0-1-0-0-0'
out_str("Hello world",11, LSB); // 'H' 0x48 will be '0-0-0-1-0-0-1-0'
I will give this a try. Is that just for character? How it be for a string like a sentence?
– M2T156
Nov 15 '18 at 15:05
It works very well for characters but not strings.
– M2T156
Nov 15 '18 at 15:17
you can iterate, knowing the length of the string. I edited the answer.
– gustavovelascoh
Nov 15 '18 at 15:24
Hi Gustav, I cannot see any difference so far. How would you do it say for example, print a sentence "Hello World"?
– M2T156
Nov 15 '18 at 15:26
Yes I have it now. I will try and let you know in a few mins.
– M2T156
Nov 15 '18 at 15:28
|
show 11 more comments
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53322096%2fbit-manipulation-ascii-with-binary%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I think you need a function like this, using MSB first:
#define MSB 1
#define LSB 0
void out_char(char character, char bit_order){
uint8_t i = 0;
RSOUT = 1 ; // MSB
__delay_ms(10);
RSOUT = 0 ; // START
__delay_us(25);
for (i = 8; i>0; --i){
if (bit_order){
RSOUT = (character & 0x80) ? 1:0;
character <<= 1;
} else {
RSOUT = (character & 0x01);
character >>= 1;
}
__delay_us(25);
}
RSOUT = 1 ; // STOP
}
void out_str(char * string, uint8_t len, char bit_order){
uint8_t i = 0;
for (i = 0; i< len; i++){
out_char(string[i], bit_order);
}
}
out_str("Hello world",11, MSB); // 'H' 0x48 will be '0-1-0-0-1-0-0-0'
out_str("Hello world",11, LSB); // 'H' 0x48 will be '0-0-0-1-0-0-1-0'
I will give this a try. Is that just for character? How it be for a string like a sentence?
– M2T156
Nov 15 '18 at 15:05
It works very well for characters but not strings.
– M2T156
Nov 15 '18 at 15:17
you can iterate, knowing the length of the string. I edited the answer.
– gustavovelascoh
Nov 15 '18 at 15:24
Hi Gustav, I cannot see any difference so far. How would you do it say for example, print a sentence "Hello World"?
– M2T156
Nov 15 '18 at 15:26
Yes I have it now. I will try and let you know in a few mins.
– M2T156
Nov 15 '18 at 15:28
|
show 11 more comments
I think you need a function like this, using MSB first:
#define MSB 1
#define LSB 0
void out_char(char character, char bit_order){
uint8_t i = 0;
RSOUT = 1 ; // MSB
__delay_ms(10);
RSOUT = 0 ; // START
__delay_us(25);
for (i = 8; i>0; --i){
if (bit_order){
RSOUT = (character & 0x80) ? 1:0;
character <<= 1;
} else {
RSOUT = (character & 0x01);
character >>= 1;
}
__delay_us(25);
}
RSOUT = 1 ; // STOP
}
void out_str(char * string, uint8_t len, char bit_order){
uint8_t i = 0;
for (i = 0; i< len; i++){
out_char(string[i], bit_order);
}
}
out_str("Hello world",11, MSB); // 'H' 0x48 will be '0-1-0-0-1-0-0-0'
out_str("Hello world",11, LSB); // 'H' 0x48 will be '0-0-0-1-0-0-1-0'
I will give this a try. Is that just for character? How it be for a string like a sentence?
– M2T156
Nov 15 '18 at 15:05
It works very well for characters but not strings.
– M2T156
Nov 15 '18 at 15:17
you can iterate, knowing the length of the string. I edited the answer.
– gustavovelascoh
Nov 15 '18 at 15:24
Hi Gustav, I cannot see any difference so far. How would you do it say for example, print a sentence "Hello World"?
– M2T156
Nov 15 '18 at 15:26
Yes I have it now. I will try and let you know in a few mins.
– M2T156
Nov 15 '18 at 15:28
|
show 11 more comments
I think you need a function like this, using MSB first:
#define MSB 1
#define LSB 0
void out_char(char character, char bit_order){
uint8_t i = 0;
RSOUT = 1 ; // MSB
__delay_ms(10);
RSOUT = 0 ; // START
__delay_us(25);
for (i = 8; i>0; --i){
if (bit_order){
RSOUT = (character & 0x80) ? 1:0;
character <<= 1;
} else {
RSOUT = (character & 0x01);
character >>= 1;
}
__delay_us(25);
}
RSOUT = 1 ; // STOP
}
void out_str(char * string, uint8_t len, char bit_order){
uint8_t i = 0;
for (i = 0; i< len; i++){
out_char(string[i], bit_order);
}
}
out_str("Hello world",11, MSB); // 'H' 0x48 will be '0-1-0-0-1-0-0-0'
out_str("Hello world",11, LSB); // 'H' 0x48 will be '0-0-0-1-0-0-1-0'
I think you need a function like this, using MSB first:
#define MSB 1
#define LSB 0
void out_char(char character, char bit_order){
uint8_t i = 0;
RSOUT = 1 ; // MSB
__delay_ms(10);
RSOUT = 0 ; // START
__delay_us(25);
for (i = 8; i>0; --i){
if (bit_order){
RSOUT = (character & 0x80) ? 1:0;
character <<= 1;
} else {
RSOUT = (character & 0x01);
character >>= 1;
}
__delay_us(25);
}
RSOUT = 1 ; // STOP
}
void out_str(char * string, uint8_t len, char bit_order){
uint8_t i = 0;
for (i = 0; i< len; i++){
out_char(string[i], bit_order);
}
}
out_str("Hello world",11, MSB); // 'H' 0x48 will be '0-1-0-0-1-0-0-0'
out_str("Hello world",11, LSB); // 'H' 0x48 will be '0-0-0-1-0-0-1-0'
edited Nov 15 '18 at 15:59
answered Nov 15 '18 at 15:00
gustavovelascohgustavovelascoh
5301417
5301417
I will give this a try. Is that just for character? How it be for a string like a sentence?
– M2T156
Nov 15 '18 at 15:05
It works very well for characters but not strings.
– M2T156
Nov 15 '18 at 15:17
you can iterate, knowing the length of the string. I edited the answer.
– gustavovelascoh
Nov 15 '18 at 15:24
Hi Gustav, I cannot see any difference so far. How would you do it say for example, print a sentence "Hello World"?
– M2T156
Nov 15 '18 at 15:26
Yes I have it now. I will try and let you know in a few mins.
– M2T156
Nov 15 '18 at 15:28
|
show 11 more comments
I will give this a try. Is that just for character? How it be for a string like a sentence?
– M2T156
Nov 15 '18 at 15:05
It works very well for characters but not strings.
– M2T156
Nov 15 '18 at 15:17
you can iterate, knowing the length of the string. I edited the answer.
– gustavovelascoh
Nov 15 '18 at 15:24
Hi Gustav, I cannot see any difference so far. How would you do it say for example, print a sentence "Hello World"?
– M2T156
Nov 15 '18 at 15:26
Yes I have it now. I will try and let you know in a few mins.
– M2T156
Nov 15 '18 at 15:28
I will give this a try. Is that just for character? How it be for a string like a sentence?
– M2T156
Nov 15 '18 at 15:05
I will give this a try. Is that just for character? How it be for a string like a sentence?
– M2T156
Nov 15 '18 at 15:05
It works very well for characters but not strings.
– M2T156
Nov 15 '18 at 15:17
It works very well for characters but not strings.
– M2T156
Nov 15 '18 at 15:17
you can iterate, knowing the length of the string. I edited the answer.
– gustavovelascoh
Nov 15 '18 at 15:24
you can iterate, knowing the length of the string. I edited the answer.
– gustavovelascoh
Nov 15 '18 at 15:24
Hi Gustav, I cannot see any difference so far. How would you do it say for example, print a sentence "Hello World"?
– M2T156
Nov 15 '18 at 15:26
Hi Gustav, I cannot see any difference so far. How would you do it say for example, print a sentence "Hello World"?
– M2T156
Nov 15 '18 at 15:26
Yes I have it now. I will try and let you know in a few mins.
– M2T156
Nov 15 '18 at 15:28
Yes I have it now. I will try and let you know in a few mins.
– M2T156
Nov 15 '18 at 15:28
|
show 11 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53322096%2fbit-manipulation-ascii-with-binary%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Use
>>=shift to iterate over bits.while (val) { output(val & 1); val >>= 1; }– Kamil Cuk
Nov 15 '18 at 14:55
How do you mean?
– M2T156
Nov 15 '18 at 15:18
Why don't use the hardware UART? A lott of PIC will support it.
– Mike
Nov 16 '18 at 6:41
Because I want to experiment with software UART.
– M2T156
Nov 16 '18 at 7:36