leto
Joined: 02 Aug 2005 Posts: 14
|
strange behavior of int32 Array |
Posted: Tue Aug 08, 2006 4:00 pm |
|
|
Hi,
I have a problem using int32 arrays. I want to load an array each time #int_ext is executed. Then, I print it pressing RB7.
If I use a variable as index as in program below it doesn't work.
Code: |
Index=4;
Values[Index] = 0x1;
|
it complete Values[3]=65536 instead of Values[4]=1.
but, when I use a numeric index directly is works ok.
With int8 arrays it works fine. Any suggestions ?
ps. Im using PIC18F452 and CCS 3.249.
thanks
Code: |
#include <18F452.h>
#device adc=10
#FUSES NOWDT //No Watch Dog Timer
#FUSES HS //High speed osc with H4 enabled 4X PLL
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOBROWNOUT //Reset when brownout detected
#FUSES NOPUT //No Power Up Timer
#FUSES NOCPD //No EE protection
#FUSES STVREN //Stack full/underflow will cause reset
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOWRT //Program memory not write protected
#FUSES NOWRTD //Data EEPROM not write protected
#FUSES NOWRTC //configuration not registers write protected
#FUSES NOWRTB //Boot block not write protected
#FUSES NOEBTR //Memory not protected from table reads
#FUSES NOEBTRB //Boot block not protected from table reads
#FUSES NOCPB //No Boot Block code protection
#use delay(clock=10000000)
#use rs232(baud=57600, parity=N, bits=8, xmit=PIN_C6, rcv=PIN_C7, errors, stream=SERIAL_PORT)
int32 Values[11];
void Print();
int Index;
#INT_RB
void tecla(void) {
int step=0;
delay_ms(20);
while (!input(PIN_B7)) {
delay_ms(100);
step+=1;
}
if (step >= 5) Print();
}
#int_ext
void external()
{
Index=4;
Values[Index] = 0x1;
printf("Vector [%d], %lu\r\n",Index,Values[Index]);
}
void Print()
{
int i;
for(i=0;i<11;i++) {
printf("Value[%i]=%lu\r\n", i, Values[i]);
}
}
//------------------------------------------
// main()
//------------------------------------------
void main()
{
/*******************************************************************
* Initialization
*******************************************************************/
setup_psp(PSP_DISABLED);
setup_wdt(WDT_OFF);
setup_timer_3(T3_DISABLED);
setup_low_volt_detect(FALSE);
setup_oscillator(False);
port_b_pullups(TRUE);
ext_int_edge(H_TO_L);
enable_interrupts(int_ext);
enable_interrupts(int_rda);
enable_interrupts(int_rb);
enable_interrupts(global);
memset(&Values[0], 0, 44);
/*******************************************************************
* main loop
*******************************************************************/
while(1);
}
|
|
|