Hi
problem not in your code ,you must understand different between characters in
bin, ASCII, hex and decimal.
your display just show your data in ASCII, then if you can't change display
format so change your data.
for example if you want send
num 1(dec) to display you must send 0x31(hex),
character A to display you must send 0x41(hex),
character a to display you must send 0x61(hex)
so just lock at below table:
________________________________
From: hasan mustafa
To: c...
Sent: Mon, September 13, 2010 12:21:57 PM
Subject: [c28x] string to hex/string problem
hello everyone,
im facing a problem, im sending a HEX values to the PC, put the PC program
display it as string, BUT i want it as HEX, i cant change the PC part, because
its displaying other information too, it will be easier for me if i change the
TI code,
for example,
i want to send 0xEA on the screen i received it as ê,,, i want to see it
as EA
i did like that
tempTXFrame= 0xEA;
ltoa(tempTXFrame,TCPTemp);
TXFrame[0] = 0x41;
TXFrame[1] = TCPTemp[0];
TXFrame[2] = TCPTemp[1];
////////////////////////
it suppose i receive 6561 but i receive on the screen 23 ?????? i think im using
the wrong function, im newbie with strings
any advice will be great, thanks all
Hasan
_____________________________________
Note: If you do a simple "reply" with your email client, only the author of this
message will receive your answer. You need to do a "reply all" if you want your
answer to be distributed to the entire group.
_____________________________________
About this discussion group:
Reply by "Prashant D. Kharade"●September 15, 20102010-09-15
Hi Hasan,
I do not have experience on DSP. I am using AVRs.
Check below my one of the functions which sends combinations of Ascii & hex to
serial port.
I am sending positive acknowledgement to a query from a PLC.
Buf[i] has 3 ascii characters, SOT (Start of text) Sequence (0x01), add
(Address- 'A' to 'Z')
Then the hex byte 0x07. Please note this can be any hex value, as per length of
the answer string.
Then the CRC. This is also Hex byte, return from a function.
Now again ascii byte 0x04 (EOT-End of string)
This is collected in a buffer ans-buf & send to serial port.
void pos_ack()
{ char ans_buf[8];
uint8_t i;
for(i=0;i<3;i++)
ans_buf[i] = buf[i];
//SOT, seq, add byte
ans_buf[3] = 0x07;
//Length byte
ans_buf[4] = 0x06;
// pos ack byte
ans_buf[5] =
calculate_recd_CRC(ans_buf,5);
ans_buf[6] = 0x04;
// EOT byte
ans_buf[7] = '\0';
uart1_puts(ans_buf);
}
Use free demo version of 'Docklight' available on net for checking the
response on PC.
You can check hex & ascii values at same time.
All the best.
Prashant D. Kharade
Pune. India
From: c... [mailto:c...] On Behalf Of hasan mustafa
Sent: 13 September 2010 13:22
To: c...
Subject: [c28x] string to hex/string problem
hello everyone,
im facing a problem, im sending a HEX values to the PC, put the PC program
display it as string, BUT i want it as HEX, i cant change the PC part, because
its displaying other information too, it will be easier for me if i change the
TI code,
for example,
i want to send 0xEA on the screen i received it as ,, i want to see it as
EA
This procedure should be easily expanded to convert 2 byte or larger numbers.
HTH,
Andrew
> hello everyone,
>
> im facing a problem, im sending a HEX values to the PC, put the PC program
> display it as string, BUT i want it as HEX, i cant change the PC part,
> because its displaying other information too, it will be easier for me if i
> change the TI code,
>
> for example,
>
> i want to send 0xEA on the screen i received it as ,, i want to see it
as
> EA
>
> i did like that
>
> tempTXFrame= 0xEA;
> ltoa(tempTXFrame,TCPTemp);
>
> TXFrame[0] = 0x41;
> TXFrame[1] = TCPTemp[0];
> TXFrame[2] = TCPTemp[1];
>
> ////////////////////////
>
> it suppose i receive 6561 but i receive on the screen 23 ?????? i think im
> using the wrong function, im newbie with strings
>
> any advice will be great, thanks all
>
> Hasan
>
_____________________________________
Note: If you do a simple "reply" with your email client, only the author of this
message will receive your answer. You need to do a "reply all" if you want your
answer to be distributed to the entire group.
_____________________________________
About this discussion group:
Reply by hasan mustafa●September 14, 20102010-09-14
hello everyone,
im facing a problem, im sending a HEX values to the PC, put the PC program
display it as string, BUT i want it as HEX, i cant change the PC part,
because its displaying other information too, it will be easier for me if i
change the TI code,
for example,
i want to send 0xEA on the screen i received it as ,, i want to see it as
EA