ivanperino
Joined: 08 Jun 2006 Posts: 14
|
trouble: for() iteration using INT32 variables |
Posted: Wed Jan 02, 2008 7:11 am |
|
|
I`m working with a pic 16f88 on a CCS 4.023 and I have trouble when I use "for()" iteration with int32 variable but it works right if I do it with a "while()" iteration.
The piece of code that doesn`t work is:
#include <C:\Archivos de programa\CCS4\Devices\16F88.h>
#device ADC=10
#fuses NOWDT,INTRC_IO, PUT, NOBROWNOUT, NOLVP, NOWRT, NOPROTECT, MCLR
...
int32 aux_d;
int8 aux_dato;
...
for(aux_d=0x00000000; aux_d <= 0x0003ffff; dir++){
aux_dato = read_ext_eeprom(aux_d);
printf("%lx -- %x\n\r",aux_d,aux_dato);
if(aux_dato != 0xff){
aux_d = 0xffffffff;
dir = aux_d + 1;
printf("%lx -- %x\n\r",aux_d,aux_dato);
}
}
...
...
It run indefinitely, the statments printf arenĀ“t necessary but they help me to debug the program. printf shows to me that for() doesn't break out.
In the other hand, the next piece of code runs right:
#include <C:\Archivos de programa\CCS4\Devices\16F88.h>
#device ADC=10
#fuses NOWDT,INTRC_IO, PUT, NOBROWNOUT, NOLVP, NOWRT, NOPROTECT, MCLR
...
int32 aux_d;
int8 aux_dato;
...
aux_d=0x0003ffff;
aux_dato = read_ext_eeprom(aux_d);
printf("%lx -- %x\n\r",aux_d,aux_dato);
while((0xff == aux_dato) & (aux_d != 0)){
aux_d--;
aux_dato = read_ext_eeprom(aux_d);
printf("%lx -- %x\n\r",aux_d,aux_dato);
}
dir = aux_d + 1;
...
using while() iteration, it works ok.
What is happening? May be a Compiler bug?
Thank you to everybody. |
|