Quote:
|
Originally Posted by chakorules
I tried that to, in the HELP FILE it list the directives:
Using directives with Print to screen
Directive
Variable
PrintToScreen Output
%ld
long x = 2000000
2000000
%d
int x = -100
-100
%u
unsigned int x = 100
100
%x
int x = 255
ff
%X
int x = 255
FF
%lx
int x = 255
0ff
%b
int x = 100
1100100
I used:
Code:
PrintToScreen ( "Loop Count = %ld\n" , (long)count ) ;
Shouldn't that work? It doesn't seem to work for me.....
The reason I changed it to:
Code:
PrintToScreen ( "Loop Count = %d\n" , (int)count ) ;
Was because I seen a tutorial or sample code of the EasyC, they used a long varible, then used a %d and an INT to print it to screen, so I followed suit but no matter which way, the printing of my count varible to screen is wacky....I can't possiblily debug like this...why or why don't these PICs support online debugging?
Yes, that is EASYC code. I printed the operatorcontrol function to PDF in the zip file.
|
Ok, so you are using EasyC. I've never used it, so I don't know how to help you with it.. but in MPLab (compiling to mcc18) %ld isn't functional. You'd have to seperate longs greater than 65535 as I have shown above. If the long is between 0 and 65535 you can cast it to an integer, and it will print alright.
The error you see may come from wraparound.. that is, the upper 2 bytes of the long are both cutoff when you cast to int. So, for example:
long test = 19203238; // 00000001 00100101 00000100 10100110
printf("botched-long: %d", (int)test); // botched-long: 1190 (00000000 00000000 00000100 10100110)
You see that the lower 2 bytes (the length of an int) are the same in both numbers, but in the cast version the upper two are cleared out. You probably already know this, but, eh, I already said it.
The PICs themselves support online debugging, but I'm guessing that IFI's setup has made this feature unavailable. They have a Dynamic Debug Tool (I 've never used it), so maybe that would be something you could look into?