MPC5604B: "sprintf(...)" is not possible

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MPC5604B: "sprintf(...)" is not possible

883 Views
Mikaza
Contributor I

Hallo together,

 

at the moment I want to transfer a serial chain of ASCII-Strings with the LIN/UART-Controller from the MPC5604B Board. So i need a function, which changes characters from binary to ASCII, so yesterday I try to use the "sprintf" - function, but without success. (stdio.h is already included).

 

How can I solve this problem? Perhaps one of you has already a solution...?

 

Best Regards and marry Christmas (and a happy new year)

Labels (1)
0 Kudos
4 Replies

543 Views
shri
Contributor II

void binarytoascii(uint16_t innum) {
uint16_t j1,in;
uint8_t p1,p2;
in = innum;

j1 = (in & 0x0f);
if (j1 > 9) p1 = (uint8_t)(j1 + 0x41 - 10);
else p1 = (uint8_t)(j1 +0x30);
j1 = (in & 0xf0) >> 4;
if (j1 > 9) p2 = (uint8_t)(j1 +0x41 - 10);
else p2 = (uint8_t)(j1 +0x30);
//TransmitCharacter(0x0a);
// TransmitCharacter(0x0d);
TransmitCharacter(p2);
TransmitCharacter(p1);
}

where TransmitCharacter() function looks like as below

void TransmitCharacter(uint8_t ch)
{
LINFLEX_0.BDRL.B.DATA0 = ch;                                /* write character to transmit buffer */
while (1 != LINFLEX_0.UARTSR.B.DTF) {}                 /* Wait for data transmission completed flag */
LINFLEX_0.UARTSR.R = 0x0002;                              /* clear the DTF flag and not the other flags */
}

 

set the proper baud rate of LINFLEX_0.UART

0 Kudos

543 Views
Mikaza
Contributor I

no hint for me?

0 Kudos

543 Views
Lundin
Senior Contributor IV

You could ask a programmer to write an binary to ASCII converter for you. It is such a basic task that even a beginner programmer should be able to succesfully help you out with it.

0 Kudos

543 Views
stanish
NXP Employee
NXP Employee

Hi Mikaza,

 

Could you perhaps post some code snippet to see how exactly you are using sprintf in this case.

 

Thanks.

Stanish

0 Kudos