CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

strange behavior of int32 Array

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
leto



Joined: 02 Aug 2005
Posts: 14

View user's profile Send private message

strange behavior of int32 Array
PostPosted: Tue Aug 08, 2006 4:00 pm     Reply with quote

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.

Code:

   Values[4] = 0x1;



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);
}
Guest








PostPosted: Tue Aug 08, 2006 7:00 pm     Reply with quote

Sorry its a mistake. Its a Proteus emulator problem.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group