EXTI PVM Wakeup Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
sprehse
Posts: 11
Joined: Thu May 21, 2020 2:59 pm
Has thanked: 3 times
Been thanked: 2 times

EXTI PVM Wakeup

Postby sprehse » Thu Feb 25, 2021 10:23 am

Hello,
i use STM32L475 and i will enable the Peripheral Voltage Monitoring (PVM) on my STM32L475 and config the EXTI for getting an interrupt,
if the voltage go under the threshhold voltage.
So my problem is, how can i config and enable the internal EXTI Event on Line 38 (VDDA detection).
in best case with a callback function.

Thanks for help

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: EXTI PVM Wakeup

Postby Giovanni » Thu Feb 25, 2021 11:54 am

Hi,

The EXTI ISR is defined in stm32_exti16-35_38.inc, basically you need to define a macro STM32_EXTI38_ISR to inject your code in the ISR (you may add it to your mcuconf.h).

You need to enable the line using extiEnableLine() or extiEnableGroup2(), see stm32_exti.c.

Giovanni

sprehse
Posts: 11
Joined: Thu May 21, 2020 2:59 pm
Has thanked: 3 times
Been thanked: 2 times

Re: EXTI PVM Wakeup

Postby sprehse » Fri Feb 26, 2021 8:42 am

Hey Giovanni,

thanks for the fast answer. Now I have create a function macro for the ISR, but i could not yet see the voltage drop at VDD, if i reduce the supply voltage to 2.2V at PLS Level 6 (2,9V).

I may not have masked the EXTI LIne 16 correctly and i am trying the extiEnableline function, later.
For the detection of VDD, it should be sufficient by default to set STM32_PVD_Enable to true in mcuconf.h and to set the PLS level, right?

in case of the VDDA detection, i must set the PVM4 bit in CR2 Register for trigger the ISR, if VDDA below 1.8V and wait until PVMO4 bit is cleared by hardware, right. Must this seqence before the hal init for analog peripherie or it is ok to set/check this bits before start the peripheral e.g ADC?

So many questions. :)

thanks for your help

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: EXTI PVM Wakeup

Postby Giovanni » Fri Feb 26, 2021 8:56 am

Try putting a breakpoint in the ISR (compile using -O0), just to make sure you get there. Settings should be in mcuconf.h but you do need to enable the EXTI line.

Giovanni

sprehse
Posts: 11
Joined: Thu May 21, 2020 2:59 pm
Has thanked: 3 times
Been thanked: 2 times

Re: EXTI PVM Wakeup

Postby sprehse » Fri Feb 26, 2021 11:32 am

Hey Giovanni,
no brakepoints are triggered. -O0 is active and i also active the asserts and checks in osalconf.h, because i jump into unhandled_exeption if i reduce the vdd voltage below 2,9V. config function will be execute after halInit()

thats my config:

mcuconf.h
#define STM32_PVD_ENABLE TRUE
#define STM32_PLS STM32_PLS_LEV6

#define STM32_EXTI_REQUIRED TRUE //activate External Interrupt peripherie
#define STM32_EXTI16_IS_USED TRUE //activate External interrupt VDD
#define STM32_EXTI38_IS_USED TRUE //activate External interrupt VDDA

#define STM32_EXTI38_ISR(pr,line) PWR_VDDA_ISR(pr,line) // ISR callback function VDDA
#define STM32_EXTI16_ISR(pr,line) PWR_VDD_ISR(pr,line) // ISR callback function VDD


function.c
/*******************************************************************************
*
* @brief Config function for activate Powermonitoring of VDDA
* @details Set PWR Register and activate the external interrupt
* lines for detection voltage drop of VDDA and VDD
*
******************************************************************************/

void stabl_Config_PWR(void){
PWR->CR2 |= PWR_CR2_PVME4; // set PVME4 Bit detection if VDDA is below 1,8V
while(((PWR->SR2 & PWR_SR2_PVMO4) == PWR_SR2_PVMO4)); // wait for PVM4 wake up time

extiEnableLine(PWR_EXTI_VDD_LINE, EXTI_MODE_RISING_EDGE); //enable internal interrupt for VDD on Rising Edge
extiEnableLine(PWR_EXTI_VDDA_LINE, EXTI_MODE_RISING_EDGE); //enable internal interrupt for VDDA on Rising Edge
}

/*******************************************************************************
*
* @brief Interrupt service rotine for voltage drop detection on VDD
* @details send CAN message to master,
* if voltage drop on supply Voltages is detected
*
******************************************************************************/
void PWR_VDD_ISR(uint32_t pr,uint8_t line){
(void) pr;
(void) line;
uint8_t candata[2] = { 0x00 }; // CAN dataarray

candata[0] = 0xF6; // Voltage Monitoring errorcode
candata[1] = 0x01; // Voltage Monitoring VDD

CAN_SendMessage(CAN_INFO, candata,2); // send out error code via CAN

}

/*******************************************************************************
*
* @brief Interrupt service rotine for voltage drop detection on VDDA
* @details send CAN message to master,
* if voltage drop on supply Voltages is detected
*
******************************************************************************/
void PWR_VDDA_ISR(uint32_t pr,uint8_t line){
(void) pr;
(void) line;
uint8_t candata[2] = { 0x00 }; // CAN dataarray

candata[0] = 0xF6; // Voltage Monitoring errorcode
candata[1] = 0x02; // Voltage Monitoring VDDA

CAN_SendMessage(CAN_INFO, candata,2); // send out error code via CAN

}



functions.h
/*******************************************************
* Defines
******************************************************/

#define PWR_EXTI_VDD_LINE 16 // EXTI Line VDD
#define PWR_EXTI_VDDA_LINE 38 // EXTI Line VDDA
/*******************************************************
* Functionprototypes
******************************************************/

void Config_PWR(void);
void PWR_VDD_ISR(uint32_t pr,uint8_t line);
void PWR_VDDA_ISR(uint32_t pr,uint8_t line);





Do you have an idea what is wrong?
Thanks a lot

Martin

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: EXTI PVM Wakeup

Postby Giovanni » Fri Feb 26, 2021 12:38 pm

If it goes in unhandled exception it is possible that the EXTI ISR is linking to the wrong IRQ vector, when the IRQ happens then it goes in the unhandled default vector. Could be a bug.

Giovanni

User avatar
FXCoder
Posts: 384
Joined: Sun Jun 12, 2016 4:10 am
Location: Sydney, Australia
Has thanked: 180 times
Been thanked: 130 times

Re: EXTI PVM Wakeup

Postby FXCoder » Fri Feb 26, 2021 1:47 pm

FYI can't see your CAN_SendMessage(...) function but calling certain ChibiOS CAN driver functions from ISR is not allowed.
--
Bob

sprehse
Posts: 11
Joined: Thu May 21, 2020 2:59 pm
Has thanked: 3 times
Been thanked: 2 times

Re: EXTI PVM Wakeup

Postby sprehse » Mon Mar 01, 2021 9:24 am

Hey Bob,
thanks for your answer. Ive disabled the makro functions in the ISR to rule out the problem, no change. For the EXTI line 16 exist three Handler could this the problem.
the ISR is not even called but jumps directly into unhandled exeption when the Line 16 is configured and the threshold voltage falls below 2.8V

#define PWR_EXTI_VDD_LINE 16 // EXTI Line VDD
extiEnableLine(PWR_EXTI_VDD_LINE, EXTI_MODE_RISING_EDGE); //enable internal interrupt for VDD on Rising Edge

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: EXTI PVM Wakeup

Postby Giovanni » Mon Mar 01, 2021 10:02 am

Hi,

Could you get the value of the CPU status register after it stops in the unhandled exception handler?

Giovanni

User avatar
FXCoder
Posts: 384
Joined: Sun Jun 12, 2016 4:10 am
Location: Sydney, Australia
Has thanked: 180 times
Been thanked: 130 times

Re: EXTI PVM Wakeup

Postby FXCoder » Mon Mar 01, 2021 10:51 am

Hi Giovanni,
One thing I noticed when researching this is wrong call of STM32_EXTI16_ISR macros (if defined) in stm32_exti21_22.inc.
Also wrong calls of STM32_EXTI35_ISR in stm32_exti16-35_38.inc.
--
Bob

Code: Select all


#if defined(STM32_EXTI19_IS_USED) || defined(STM32_EXTI21_IS_USED) ||       \
    defined(__DOXYGEN__)
#if !defined(STM32_DISABLE_EXTI1921_HANDLER)
/**
 * @brief   EXTI[0], EXTI[1] interrupt handler.
 *
 * @isr
 */
OSAL_IRQ_HANDLER(STM32_EXTI1921_HANDLER) {
  uint32_t pr;

  OSAL_IRQ_PROLOGUE();

  extiGetAndClearGroup1((1U << 19) | (1U << 21), pr);

  /* Could be unused.*/
  (void)pr;

#if defined(STM32_EXTI19_ISR)
  STM32_EXTI16_ISR(pr, 19);
#endif
#if defined(STM32_EXTI21_ISR)
  STM32_EXTI16_ISR(pr, 21);
#endif

  OSAL_IRQ_EPILOGUE();
}
#endif
#endif

Code: Select all

#if defined(STM32_EXTI35_ISR)
  STM32_EXTI35_ISR(pr, 35);
#endif
#if defined(STM32_EXTI36_ISR)
  STM32_EXTI35_ISR(pr, 36);
#endif
#if defined(STM32_EXTI37_ISR)
  STM32_EXTI35_ISR(pr, 37);
#endif
#if defined(STM32_EXTI38_ISR)
  STM32_EXTI38_ISR(pr, 38);


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 6 guests