Language: C PIC: 16F84A Programm:CCS PCW
When I compile the following code, my compiler complains that the FOR is always true(Maybe the int i doesnt support negative values?):
#include <16F84A.h>
#FUSES XT
#use delay(clock=4M)
byte const display[10] = {63,6,91,79,102,109,124,7,127,103};
void main()
{
set_tris_b(0);
while(True)
{
int i;
for(i=9;i>=0;--i)
{
output_b(display[i]);
delay_ms(300);
}
}
}
Its PIC Countdown project, so: 9,8,7,6,5,4,3,2,1,0,9,8,7,6,5,4,3,2,1,0,9,8,7,6,... but its stops after the first cycle.
use
signed int i;
instead of
int i;
integers are unsigned by default in CCS compilers.
http://www.ccsinfo.com/downloads/ccs_c_manual.pdf
Check page 38
"All types, except float, by default are unsigned; however, [they] may be preceded by unsigned or signed.