“long” Variables, or other Variables “Cast” to “long”, need a Format Specifier of “l” or “j”. (see line 221, in file “vfprintf.c”).
“unsigned int” Variables, or other Variables “Cast” to “unsigned int”, need a Format Specifier of “u”. (see line 351, in file “vfprintf.c”).
Re-Write your “printf(…)” like this:
printf ( "%4d %4l %4d %6l %6l %6l %6l %4d %4d %6u %6u\n", (int)loop,
(long)Timer_1, (int)Step, (long)Position_X, (long)Position_Y,
(long)ENC_X, (long)ENC_Y, (int)ACC_X, (int)ACC_Y,
(unsigned int)Ultrasonic_Front, (unsigned int)Ultrasonic_Rear );
You might want to expand the width of the Second Field, “(long)Timer_1” to a more “practical” width.
Further Information:
The MCC18 Compiler has 8 bit “char”, and 16, 24, and 32 bit “int” variables, than can be printed with the “printf(…)” function.
The “printf(…)” is a “wrapper” for the “vfprintf(…)” function. You can view the ‘C’ Source Code here, “.\mcc18\src\traditional\stdclib\vfprintf.c”
A note for future reference:
The MCC18 Library’s “printf(…)” function, does not support “float” and “double” variables. But does support alternate BASE Systems for “char” and “int” types, like Binary, Octal, and Hexadecimal.