Dear friends
i would like to know how to send any bit of a char to any port pin ie. unsigned char a = 0xAA; now at memory location for a will contains 10101010b can i send the bit 0 of "a" to P1_0? i don't want to send the entire a to P1
thanking you
sunish
assembler: clr setb C: setb
both are very well documented, assembler in "the bible" C in the Keil manuals.
Erik
thanks for the suggestions
i am not trying to transmit the content of a to any distance. just assume, i'd connected 7 i/o devices to port 1, and just want toggle the status of led connected to the 8th pin of port 1 according to the value of bit 0 of char a. here i need to send the bit 0 of char a.that's what all i need without affecting the status of the other pins of port1
regards
One way is:
bdata char aByte;
P0^0 = aByte^0;
OR
char aByte;
P0^0 = aByte & 0x01;
Note you may have to use:
P0^1 = (aByte & 0x02) != 0; I am not sure how the compiler handles this
This is a funny thread. The answer to the OPs question is available in the fifth post. After that follows incomplete code that tries to answer a question I haven't seen.
What this thread needs, is for the OP to read post #2 and come back with more info, i.e. may the original question be the result of a misunderstanding.
well, that's why I wrote I cannot help him with that, as I don't know the processor (do you...?)
Modulus and circular buffers aside ...
The code is incomplete, non-functional, and rubbish anyway.
And it doesn't even answer the OPs original question!
yap, correct. but I was trying to save lives....
the modulus operator is just about the slowest thing you can use in '51 c code.
thus, make circular buffer size a power of two and then the access is ... [index & (BUFFER_SIZE - 1)]
yavuz, obviousely, you cannot infinitely increase the size of your buffer! that is a big problem indeed! I have corrected your code below to make is circular buffer. there are of course many other options!
char MyBuffer[20],output; // buffer and current display output int i=0; // counter while (output != '$') // "$" key is the end of dos string { MyBuffer[i % 20] = output; i++; }
yes and i gave code in the other place for uart but it was used.
what is the problem?
you make the enhanmecent like this; now here you go to 25 characters
char MyBuffer[25],output; // buffer and current display output
by the way, yavuz, your code can buffer overflow without any problem. try to deal with 21 characters...
yavuz, yavuz, yavuz... help your friedn with something else rather than chewed C code...how about showing him how to work/configure a peripheral like the UART? I cannot help him with that, as I don't know the processor (do you...?)
for the transmit the code needs o be this
use a buffer like MyBuffer[20], as you know you can now put 19 characters in this buffer. if your strings are fixed for example always 5 chars, test if the 6th char was sent, or use $ or any other characteur for finnishing the string. Don't forget to send the previous chars in the buffer.
for example:
char MyBuffer[20],output; // buffer and current display output int i=0; // counter while (output != '$') // "$" key is the end of dos string { MyBuffer[i] = output; i++; }
hope this helps better whot the last do
didn't he want to send data, rather than to receive it?
View all questions in Keil forum