USB CDC Question

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

USB CDC Question

472 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ub3r on Tue Sep 18 05:27:04 MST 2012
Hi Guys,

Im playing with the USB CDC code, and its working well.
Im currently sending strings like this:

serBuf2 = "Welcome to my CDC Program";
USB_WriteEP (CDC_DEP_IN, (unsigned char *)&serBuf2[0], 32);


Output:
Welcome to my CDC Program



Now i want to add a variables to my string.. like this:

int temperature = 25;
serBuf2 = ([I]I dont know what to put here[/I]);
USB_WriteEP (CDC_DEP_IN, (unsigned char *)&serBuf2[0], 32);


Wanted Output:
Temperature today is: 25 degrees.


But i don't know how to do it.

cheers
0 Kudos
Reply
3 Replies

447 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ex-kayoda on Tue Sep 18 07:04:22 MST 2012

Quote: ub3r
:confused:

Why does my 'flash used' go from 5421kb -> 16547kb after sprintf????



Because you use sprintf  :confused::eek::confused:

Read: 'Reducing codesize of printf'  http://support.code-red-tech.com/CodeRedWiki/UsingPrintf
0 Kudos
Reply

447 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ub3r on Tue Sep 18 06:59:25 MST 2012
:confused:

Why does my 'flash used' go from 5421kb -> 16547kb after sprintf????
0 Kudos
Reply

447 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ub3r on Tue Sep 18 06:48:10 MST 2012
Ok answered my own question
Just used sprintf.. :rolleyes:


char data[32];
int var = 0;

sprintf (data, "Temperature: %d", var);
USB_WriteEP (CDC_DEP_IN, (unsigned char *)data, 32);
0 Kudos
Reply