This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

fiq_handler

Hi,

I want to handle my adc interrupt in a fiq using realview. I set the correct bit in the VICIntSelect register and changed the FIQ_Handler to adc_isr. now my program isn't working any more. can someone tell me what's wrong on the following code.

; MY START UP CODE

;  Startup Code must be linked first at Address at which it expects to run.
                EXTERN  adc_isr
                AREA    RESET, CODE, READONLY
                PRESERVE8
                ARM


; Exception Vectors
;  Mapped to Address 0.
;  Absolute addressing mode must be used.
;  Dummy Handlers are implemented as infinite loops which can be modified.

Vectors         LDR     PC, Reset_Addr
                LDR     PC, Undef_Addr
                LDR     PC, SWI_Addr
                LDR     PC, PAbt_Addr
                LDR     PC, DAbt_Addr
                NOP                            ; Reserved Vector
;               LDR     PC, IRQ_Addr
                LDR     PC, [PC, #-0x0120]     ; Vector from VicVectAddr
                LDR     PC, FIQ_Addr

Reset_Addr      DCD     Reset_Handler
Undef_Addr      DCD     Undef_Handler
SWI_Addr        DCD     SWI_Handler
PAbt_Addr       DCD     PAbt_Handler
DAbt_Addr       DCD     DAbt_Handler
                DCD     0                      ; Reserved Address
IRQ_Addr        DCD     IRQ_Handler
FIQ_Addr        DCD     FIQ_Handler

Undef_Handler   B       Undef_Handler
SWI_Handler     B       SWI_Handler
PAbt_Handler    B       PAbt_Handler
DAbt_Handler    B       DAbt_Handler
IRQ_Handler     B       IRQ_Handler
FIQ_Handler     B       adc_isr


/**********************************************/
/* initialisation of the adc                  */
***********************************************/
void init_adc
{
  uint8 channel;

  for(channel = 0; channel < MAX_ADC_INPUTS; channel++)
  {
    adc_data[channel].adc_active = FALSE;
  }

  PCLKSEL0 |= (0x01 << 24);          /* Set ADC clock to CPU clock       */
  PCONP    |= (1 << 12);             /* Enable CLOCK into ADC controller */
  PINSEL1  |= (0x01 << 14) | (0x01 << 16) | (0x01 << 18);

  AD0CR = (0x07 <<  0) |  /* SEL = 3, select channel 0 and 1 on ADC0     */
          (15   <<  8) |  /* CLKDIV - 1                                  */
          (0    << 16) |  /* BURST = 0, software controlled              */
          (0    << 17) |  /* CLKS  = 0, 11 clocks/10 bits                */
          (1    << 21) |  /* PDN   = 1, normal operation                 */
          (0    << 22) |  /* TEST1: 0 = 00                               */
          (0    << 24) |  /* START = 0 A/D conversion stops              */
          (0    << 27)  ; /* EDGE  = 0 (CAP/MAT singal falling,
                                              trigger A/D conversion)    */

  VICIntSelect |= (1 << ADC0_INT);
  VICIntEnable  = (1 << ADC0_INT);
  enable_timer_process(TMR_handle_adc_inputs);
  return(TRUE);

}

/*************************** FUNCTION ************************************/
void adc_isr(void) __irq
/*************************** INFO ****************************************
**
** DESCRIPTION : adc interrupt for channel 1..MAX_ADC_INPUTS
**
** INPUT       :
**
** OUTPUT      :
**
** RETURN      :
**************************************************************************/
{
  static uint8  adc_sample_count = (uint8)ADC_SAMPLE_COUNT;
  static uint32 adc_value[3];

  adc_value[0] += (*((uint16*)(ADC_DATA_REGISTER + 0)));
  adc_value[1] += (*((uint16*)(ADC_DATA_REGISTER + 4)));
  adc_value[2] += (*((uint16*)(ADC_DATA_REGISTER + 8)));

  adc_sample_count--;

  AD0INTEN = 0x000;
  AD0CR &= ~(1 << 16);  /* Disable ADC burst mode */

  FIO2CLR = 0x00000040;
  }

  VICVectAddr = 0;   /* Acknowledge interrupt */
}

0