How to modify the register AFIO_EXTICR4

Hello,

I am working with the NUCLEO-F103RB board and I am using the USER pushbutton on PC13 to create an interrupt.


I would like to modify the AFIO_EXTICR4 register to force PC13 as in the screenshot below:

I write this code line :

AFIO->EXTICR = AFIO->EXTICR | AFIO_EXTICR4_EXTI13_PC;

The IDE indicates an error !

Can you tell me the correct syntax to modify this register.


Thank you very mutch for your help.


Best regrads

Marc

Parents
  • Hi Marc,

    EXTICR is defined as an array of 4 in the header file:

    typedef struct
    {
      __IO uint32_t EVCR;
      __IO uint32_t MAPR;
      __IO uint32_t EXTICR[4];
      uint32_t RESERVED0;
      __IO uint32_t MAPR2;  
    } AFIO_TypeDef;

    so, to set a bit in the EXTICR4 you would need to write:

      AFIO->EXTICR[3] = AFIO->EXTICR[3] | AFIO_EXTICR4_EXTI13_PC;

Reply
  • Hi Marc,

    EXTICR is defined as an array of 4 in the header file:

    typedef struct
    {
      __IO uint32_t EVCR;
      __IO uint32_t MAPR;
      __IO uint32_t EXTICR[4];
      uint32_t RESERVED0;
      __IO uint32_t MAPR2;  
    } AFIO_TypeDef;

    so, to set a bit in the EXTICR4 you would need to write:

      AFIO->EXTICR[3] = AFIO->EXTICR[3] | AFIO_EXTICR4_EXTI13_PC;

Children