I just recently ordered a teensy 2, after weeks of troubles with a broken copy (?).
Now, it's just plain fun!
It's been over 10 years since I tried programming C in a decent way. Being new in chips & microcontrollers, to understand hardware-programming, I decided to try Arduino-teensyduino-interface first.
After blinking leds, I managed to get my teensy talking over Serial & Uart, having conversations with an old windows-based gps.
But, while using sprintf to build some strings, I wonder about performance & datatypes.
int Data1=0, Data2=0, Data3=0;
Data1=999999; // Need to be able to send at least 6 "9"s.
Not entirely the way I dit it, but something like that, you get the point. It prints (something) in real life.
Now, it's sending all kind of stuff, but the problem is that "999999" and "99999" get turned in some number that doesn't reflect at all what I'm trying to send, turned in something like 19382, or -32000 and a bit... Probably just overflowed?
So, I've got a couple of questions:
1. What am I doing wrong? Which datatype am I supposed to use to print integers like 999999 (6 9s)? int? double? long?
I don't need floatingpoint-possibilities, just positive numbers. And some negatives but those are quite smaller (temperature-like).
2. Am I actually using the correct flags for sprintf (%u, %i) to build my string?
3. Performance-wise, is there a better option than sprintf to build my string? And get it over the Uart?
4. Is it okay to use char* for my send-string or would it be better to just use a fixed char[xxxx]-size-thing? Ending it with "\0"?
Pretty newbie-questions, I know... but after trying some different things with doubles, longs & floats, I seem to be doing something wrong.
Thanks in advance.