AnsweredAssumed Answered

Is there any limitation in the code size, in Events.c

Question asked by pablo palomba on Apr 2, 2008
Latest reply on Apr 27, 2008 by bigmac
Hi,
  I´m using CW6.1 and I`m working with 908AP32, I'm using two timers, the TimeBase, SPI, IIC, and SCI ports, also I´m using KBI interrupts.

The timers are used to launch SPI adcquisition. For each interrupt, clock on SPI pin is generated, and the SPDR register is filled with data output of an ADC 12bits (MCP3204).

The code of one of the interrupts is next.

I can see the clock on SPI pin, so the code is working, but I notice that the size, for example, in KBI interrupt produce a strange execution.
The problem is all information saved (if it is saved!) in Datos[x][y].wordsep.alto/bajo, it isn´t!.
For those reasons, I`m asking if  is there any limitation, and why is it?

Please, I will appreciate any suggestion!

Thanks in advance!

B_Conf

void Muestreo_C_fase_OnInterrupt(void)
{

     byte aux1;
   
        
    clrReg8Bits(PTA, CS_3204Ten);        
   
    asm
    {                                                                                 //258 ciclos `por simulación
       LDHX #@aux                                                          //#C=3
       adquiere:
           mov #$00,SPDR                                                //#C=4
       reviso: brclr 7,SPSCR,reviso                                   //#C=5    
           lda SPDR                                                           //#C=3 cargo spdr en a, fijate que uso el index arriba no ACCA
           sta ,X                                                                  //#C=2 después cargo A en la posición aux+Index
           incx                                                                    //#C=1
           cpx #@aux+3                                                     //#C=2
           bne adquiere                                                     //#C=3
                                                                                     //total= 23*3=69 ciclos de reloj
    }
   
    setReg8Bits(PTA, CS_3204Ten);                             //Deshabilito A/D de tensión y pongo el buffer en Tri State 
    
    aux[2]=aux[2]>>5;                                                   //#15
    aux1=aux[1];                                                           //#6
    aux1=aux1<<3;                                                      //#15
    aux[2]=aux[2]|aux1;                                                //#7
    aux[1]=aux[1]>>5;
    aux[0]=aux[0]<<3;
    aux[1]=aux[1]|aux[0]|0xF0;                                      //0xF0: cuando niego el dato queda bien!.
      
    Datos[0][ind].wordsep.alto= aux[1];
    Datos[0][ind].wordsep.bajo=aux[2];
 
 //  ADQUISICIÖN DE CORRIENTE  
  
    clrReg8Bits(PTA, CS_3204Cor);
    asm
    {                                                                                   //258 ciclos `por simulación
       LDHX #@aux                                                            //#C=3
       adquiereI:
         mov #$00,SPDR                                                     //#C=4
       revisoI: brclr 7,SPSCR,revisoI                                   //#C=5    
         lda SPDR                                                               //#C=3 cargo spdr en a, fijate que uso el index arriba no ACCA
         sta ,X                                                                     //#C=2 después cargo A en la posición aux+Index
         incx                                                                       //#C=1
         cpx #@aux+3                                                        //#C=2
         bne adquiereI                                                      //#C=3
                                 
    }
    setReg8Bits(PTA, CS_3204Cor);
    //Control_Placas_PutBit(6,1);  //Deshabilito A/D de corriente
   
    aux[2]=aux[2]>>5;                                                       // #15
    aux1=aux[1];                                                                //   #6
    aux1=aux1<<3;                                                           //#15
    aux[2]=aux[2]|aux1;                                                     //#7
    aux[1]=aux[1]>>5;
    aux[0]=aux[0]<<3;
    aux[1]=aux[1]|aux[0]|0xF0;                                        //0xF0: cuando niego el dato queda bien!.
 
    Datos[1][ind].wordsep.alto=aux[1];        
    Datos[1][ind].wordsep.bajo=aux[2];                            // Evita que se vaya de rango.
    ind++;
    if(ind==260)
   {
        aux1=Muestreo_C_fase_Disable();                        /*DESHABILITO INTERRUPCIÓN POR timer*/
        Cpu_Delay100US(1000);
        ind=0;
        aux1=AD3204_Disable();
        Cpu_Delay100US(1000);
   }


}    
      

Outcomes