Skip to main content
Visitor II
June 5, 2020
Question

Can one generate an interrupt from Port C pin 0 or pin 1 on the STM8L051F3?

  • June 5, 2020
  • 4 replies
  • 1052 views

There do not seem to be definitions for Port C to be used as such.

  //EXTI_SelectPort(EXTI_Port_C);

  //EXTI_SetHalfPortSelection(EXTI_HalfPort_C_LSB, ENABLE);

  //EXTI_SetPortSensitivity(EXTI_Port_C, EXTI_Trigger_Falling);

Is there any way to trigger a falling interrupt for input on Port C Pin 0 (pin 18 on the tssop 20 package)?

    This topic has been closed for replies.

    4 replies

    AClap.1Author
    Visitor II
    June 10, 2020

    I am very interested if anyone else is able to make a port C pin 1 (or 0) generate an interrupt. In the STM8L051 datasheet, it says "Up to 18 I/Os, all mappable on interrupt vectors"... so I'm hopeful that it is possible. The absence of definitions for PORTC in the Port-based portions of EXTI in the SPL make me suspect it is possible, but that I must use EXTI0/EXTI1 directly with the pin.

    Here is the skeleton of what I'm trying to do. It compiles and runs, but no interrupts are created when I toggle the input pin from an external source, and nothing is ever added to the Fifo. I know the Fifo works, as I've debugged it many other ways. Can anyone point me in the direction of what I may be missing or not understanding?

    // Configure EXTI
    void EXTI_Config(void) {
     GPIO_Init(GPIOC, GPIO_Pin_1, GPIO_Mode_In_FL_No_IT);
     EXTI_SetPinSensitivity(EXTI_Pin_1, EXTI_Trigger_Falling);
    }
     
    // int. handler ---- inputFifo is created as volatile
    // TimingElapsed is a TIM3 based counter, like micros()
    void EXTI1_IRQHandler() __interrupt(9) {
     uint32_t now = TimingElapsed;
     RINGFIFO_WR(inputFifo, (uint8_t)(now - then));
     then = now; 
     EXTI_ClearITPendingBit(EXTI_IT_Pin1);
    }

    Visitor II
    June 13, 2020

    I know nothing of your circuit or software, but sure you can use PC0/1 for external interrupts.

    AClap.1Author
    Visitor II
    June 13, 2020

    Thank you Cristian. That is very good to hear. Do happen to have any idea why there are no definitions in the SPL for EXTI_Port_C, EXTI_HalfPort_C_LSB, etc., while there are defines for ports A,B,D-H ?

    Visitor II
    June 15, 2020

    I don't know the definitions in the tools you use, but it's probably a more general thing, not really 100% specific to STM8L051F3. Maybe they are missing as there is not port C specific interrupt, as for ports B & D (see interrupt vector table). In case you miss any definitions, just use the ones from the data sheet and the reference manual RM0031.