Quantcast
Channel: MSP430 Technical Forums
Viewing all articles
Browse latest Browse all 2077

Issue with char to string conversion on MSP430

$
0
0

Hi,

 

i am actually struggling with some char to string conversion issues.

 

Running the below code on a CC3200 gives me the output is expect but on the MSP430 it does generate this strange code:

- - -117fffffff80øC
 

It looks like the first wrong data (char) gets extended to a long.

and for the second i have no idea.

Do i use the function in the correct way?

What might be wrong?

 

Thanks for any help and hint on where to have a closer look.

 

Note: importing the code into CCS gives also the right, expected result. So with debugging here does not help.

 

// Add setup code
void setup() {
   
    delay(1000);
   
    Serial.begin(115200);  // start serial for output
    Serial.println();
   
}

// Add loop code
void loop() {

  String reportString2 = "- - -";

  reportString2 += String(((char)0x01),HEX);
  reportString2 += String(((char)0x01),HEX);
  reportString2 += String(((char)0x7F),HEX);

  // below lines do not work on MSP430F5529
  reportString2 += String(((char)0x80),HEX);
  reportString2 += String(((unsigned char)0x01),HEX);
 
  Serial.println(reportString2);
  delay(200);
}


Viewing all articles
Browse latest Browse all 2077

Trending Articles