dear sir I am writing c code to write to rs232 port using aduc831 kit SBUF=1+48; SBUF=1+48; SBUF=1+48; SBUF=1+48; initially sbuf didnt take SBUF=1 doing above it did but now want to send nibble continuously from io port P3 such that it should display 0 to 0f on hyperterm now frm program 0f 1111 should be displayed on hyperterm.kindly help regards khn
Of course SBUF can handle the value 1. But the value 1 isn't the printable character '1' but a control character that many terminal programs will not show.
So you either give '1' to SBUF, or you feed it 1 + '0'. Avoid using magic numbers like 48 in your code - it is way easier to see '0' and understand that your goal is to emit printable digits.
But next thing is that you can't normally feed SBUF multiple values directly after each other, unless your specific chip have a FIFO that can queue many characters for transmission. The world is full of small hello-world applications that shows you how to send characters one-by-one, while waiting for one to transmit before trying to send the next character.
If you have a byte that you want to emit as nibbles, you can get the values to print with: Low nibble:
SBUF = (num & 0x0f) + '0';
High nibble:
SBUF = ((num >> 4) & 0x0f) + '0';
If "num" is a 16-bit number, you just have to shift 8 and 12 steps to get the other two nibbles.
By the way - do not format your text as code. It is _only_ source code that should use the "pre" tags - notice how your original post becomes very wide? Text within the pre tag doesn't get any automatic line breaks, so you can quickly create truly borked message threads. Too clever formatting is a good way to get people to ignore your posts.
Per posted: you can't normally feed SBUF multiple values directly after each other, unless your specific chip have a FIFO
is the very basic problem 48+1 would, with proper coding, produce a '1'. The other issues should follow
Erik
Even if your specific chip does have a FIFO, you still need to take steps to ensure that you don't over-fill it!