Dear
I want to send float value through serial port communication in TMS320F28027
The example project in control suite gives idea to send the character.
Please guide me
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Dear
I want to send float value through serial port communication in TMS320F28027
The example project in control suite gives idea to send the character.
Please guide me
A float value can be treated as if it is multiple chars (bytes) concatenated together. It is just bits like a char, but longer. The tricky part is that for f28027, a char is treated as 16-bits, even though it actually only uses 8-bits. So if you define an array of char, each entry is given 16-bits instead of 8. Use sizeof(float) to determine what the compiler thinks of the length, and you can view the memory of a float variable in the Memory WIndow of the CCS debugger to verify. Once you're confident of the number of bytes to send, modify your code (or the example) to send that many.
I had used
Char *msg;
float x=2.43;
msg=itoa(x, msg,10);
xmit(msg);
But it is not working
Even I had replaced float with int
Is there any header file to be added
Dear
In above there is reverse function for which CCS shows there is error
Also I have question if I add any header file viz string.h to include some functions does all the contents of string.h gets added to our programming, or only that fiction which is required gets added
dEAR
i HAD MADE changes to existing Sci_Echoback.c example project
msg = "\r\n\n\nHello World!\0";
scia_msg(msg);
msg = "\r\nYou will enter a character, and the DSP will echo it back! \n\0";
scia_msg(msg);
for(;;)
{
msg = "\r\nEnter a character: \0";
// msg = "\r\n ";
scia_msg(msg);
// Wait for inc character
while(SciaRegs.SCIFFRX.bit.RXFFST !=1) { } // wait for XRDY =1 for empty state
// Get character
ReceivedChar = SciaRegs.SCIRXBUF.all;
// Echo character back
msg = "You sent: \0";
scia_msg(msg);
scia_xmit(ReceivedChar);
// adc=(int)(ir_grid*100);
adc=(int)(12.45);
ltoa(adc, msg);
scia_msg(msg);
}
The ouput is shown below
Hello World!
You will enter a character, and the DSP will echo it back!
Enter a character: You sent: A12
Enter a character: 12A12
Enter a character: 12A12
Enter a character: 12A12
Why the number 12 is repeated again and why "You sent" is not displayed