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

STR7 external interrupt

Hello,

I'm using a STR710FZ2 uC with an external adc. When conversion is ready, the adc toggles a pin low which is connected to P1.11.

I want an interrupt to be generated on the falling edge of P1.11 so the adc value can be read.

As far as I can see I've initialised the XTI and the EIC correct, but it doesn't seem to work.

Any suggestions?

Here is some of my code.


/*************************************************
**  INIT ADC
*************************************************/
void init_adc(void)
{
 config_gpio_port(PORT_1, 0x0001 << EXAD_DOUT,   GPIO_INPUT_PP );
 config_gpio_port(PORT_1, 0x0001 << EXAD_DREADY, GPIO_INPUT_PP );
 write_gpio_pin(  PORT_1, EXAD_SCLK, FALSE);
 write_gpio_pin(  PORT_1, EXAD_DIN,  FALSE);
 config_gpio_port(PORT_1, 0x0001 << EXAD_SCLK,   GPIO_OUTPUT_PP);
 config_gpio_port(PORT_1, 0x0001 << EXAD_DIN,    GPIO_OUTPUT_PP);

 /* disable external interrupt, active on falling edge of IN_ADC_BUSY    */
 config_interrupts(DISABLE);
 config_irq_channel(IRQ_CHANNEL_XTI, DISABLE);

 XTI->PRH  = 0x00;
 XTI->PRL  = 0x00;
 XTI->MRH  = 0x00;
 XTI->MRL  = 0x40;
 XTI->TRH  = 0x00;
 XTI->TRL  = 0x00;
 XTI->CTRL = 0x00;
 XTI->CTRL = 0x02;

 config_irq_channel_priority(IRQ_CHANNEL_XTI, IRQ_PRIORITY_XTI);
 config_interrupts(ENABLE);
}


/********************************************
**  ADC ISR
********************************************/
void external_adc_interrupt(void) __arm
{
  unsigned int adc_value;

  line_value = XTI_InterruptLineValue();
  XTI_PendingBitClear(line_value);

  value = read_external_adc_value();
}

/******************************************
** Peripherals IRQ Handlers Address Table
******************************************/
PUBLIC          IRQ_Vectors
IRQ_Vectors:

T0TIMI_Addr:    DD      timer_interrupt?A
FLASH_Addr:     DD      FLASHIRQHandler
RCCU_Addr:      DD      RCCUIRQHandler
RTC_Addr:       DD      RTCIRQHandler
WDG_Addr:       DD      WDGIRQHandler
XTI_Addr:       DD      external_adc_interrupt?A
USBHP_Addr:     DD      USBHPIRQHandler
I2C0ITERR_Addr: DD      I2C0ITERRIRQHandler
I2C1ITERR_Addr: DD      I2C1ITERRIRQHandler
UART0_Addr:     DD      uart_isr?A
UART1_Addr:     DD      uart_isr?A
UART2_Addr:     DD      uart_isr?A
UART3_Addr:     DD      uart_isr?A
BSPI0_Addr:     DD      BSPI0IRQHandler
BSPI1_Addr:     DD      BSPI1IRQHandler
I2C0_Addr:      DD      I2C0IRQHandler
I2C1_Addr:      DD      I2C1IRQHandler
CAN_Addr:       DD      CANIRQHandler
ADC12_Addr:     DD      adc_isr?A
T1TIMI_Addr:    DD      T1TIMIIRQHandler
T2TIMI_Addr:    DD      T2TIMIIRQHandler
T3TIMI_Addr:    DD      T3TIMIIRQHandler
                DD      0                   ; Reserved
                DD      0                   ; Reserved
                DD      0                   ; Reserved
HDLC_Addr:      DD      HDLCIRQHandler
USBLP_Addr:     DD      USBLPIRQHandler
                DD      0                   ; Reserved
                DD      0                   ; Reserved
T0TOI_Addr:     DD      T0TOIIRQHandler
T0OC1_Addr:     DD      T0OC1IRQHandler
T0OC2_Addr:     DD      T0OC2IRQHandler


  • Hello

    Please follow next steps:

    1. Configure the mask bits of the 16 wake-up lines (XTI_MRL, XTI_MRH).
    2. Configure the triggering edge registers of the wake-up lines (XTI_PRL, XTI_TRH).
    3. In the EIC registers, enable the IRQ5 interrupt channel so an interrupt coming from one of the 16 wake-up lines can be correctly acknowledged.
    4. Clear the WKUP-INT bit in the XTI_CTRL register to disable Wake-up Mode and enable interrupt mode. Set the ID1S bit in the XTI_CTRL register to enable the 16 wake-up lines as external interrupt source lines.
    5. Configure port pin as input.

    In your case:
    1. XTI_MRL = 0x40
    2. XTI_PRL = 0x00
    3. EIC_IER = 0x00000020
    4. XTI_CTRL = 0x02
    5. GPIO1_PC0 = 0x0800

    This procedure is tested in simulator and it works.

    Regards,
    Sasa

  • Thanks for your reaction but I have read the manual to and for some weird reason it doesn't work in practice.

    When I use the debugger all the correct bits are set in the right order. and I can see that the pending bit in the EIC is set, but I don't seem to get into the xti irq_handler.

    any suggestions??

    kind regards
    Sander

  • It's possible that you use another interrupt with higher priority, so the XTI interrupt is not handled.

    The easiest way to solve this problem would be, that you sent me the whole project, so that I can debug it.

    Thanks,
    Sasa
    E-mail: sb@keil.com