STM32L4 PVD configuration
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-03-21 5:27 AM
Hello there,
I am using the STM32L4 family MCU. In my hardware design, only after the USB cable is connected the voltage is applied to the VDD_USB pin of the MCU. At no USB connection this voltage is not present.
As a follow-up to this discussion, I am trying to configure everything now:
https://community.st.com/0D50X00009XkhQCSAZ
My problem consists of 2 sub-problems:
- I cannot get the PVM1 (EXTI35) interrupts to work.
- I dont know what is the PVM1 wakeup time.
The procedure described in the datasheet is as follows:
What I do is the following:
- I enable the PVM1 interrupt:
In the generated code I see it is enabled:
/**
* Initializes the Global MSP. */void HAL_MspInit(void){ /* USER CODE BEGIN MspInit 0 *//* USER CODE END MspInit 0 */
__HAL_RCC_SYSCFG_CLK_ENABLE();
__HAL_RCC_PWR_CLK_ENABLE();HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
/* System interrupt init*/
/* MemoryManagement_IRQn interrupt configuration */ HAL_NVIC_SetPriority(MemoryManagement_IRQn, 0, 0); /* BusFault_IRQn interrupt configuration */ HAL_NVIC_SetPriority(BusFault_IRQn, 0, 0); /* UsageFault_IRQn interrupt configuration */ HAL_NVIC_SetPriority(UsageFault_IRQn, 0, 0); /* SVCall_IRQn interrupt configuration */ HAL_NVIC_SetPriority(SVCall_IRQn, 0, 0); /* DebugMonitor_IRQn interrupt configuration */ HAL_NVIC_SetPriority(DebugMonitor_IRQn, 0, 0); /* PendSV_IRQn interrupt configuration */ HAL_NVIC_SetPriority(PendSV_IRQn, 15, 0); /* SysTick_IRQn interrupt configuration */ HAL_NVIC_SetPriority(SysTick_IRQn, 15, 0);/* Peripheral interrupt init */
/* PVD_PVM_IRQn interrupt configuration */ HAL_NVIC_SetPriority(PVD_PVM_IRQn, 5, 0); HAL_NVIC_EnableIRQ(PVD_PVM_IRQn);/* USER CODE BEGIN MspInit 1 */
/* USER CODE END MspInit 1 */
}2. I enable the PVM1:
/**
* @brief Enable the Power Voltage Monitoring 1: VDDUSB versus 1.2V. * @retval None */void HAL_PWREx_EnablePVM1(void){ SET_BIT(PWR->CR2, PWR_PVM_1); }3. Now I need to wait the ''PVM1 wakeup time'' but since I have no idea what is this time or I cant wait for the PVM1 interrupt as it doesnt work (I dont know why) I am stuck.
The PVM1 interrupt should work when I apply or remove voltage from VDD_USB if I understand correctly. For me it does not. Also the datasheet doesnt specify at any point what is the ''PVM1 wakeup time''.
When I use the debugger I see that the program acts as there is power (even though I do not supply it) but after I stop on the next line, I can see in the PWR_SR2 register that the flag is correct. It feels like its already to late when I stop with debugger and the flag changes...
As a prove, let me show you this case:
I have no USB cable connected, thus VDD_USB is near 0 V. This function returns ''true'':
bool usbds_isPowerPresent()
{ return (!HAL_IS_BIT_SET(PWR->SR2, PWR_SR2_PVMO1));}Now, this modified version of the function returns false:
bool usbds_isPowerPresent()
{ volatile uint32_t dummy = HAL_IS_BIT_SET(PWR->SR2, PWR_SR2_PVMO1); (void)dummy; return (!HAL_IS_BIT_SET(PWR->SR2, PWR_SR2_PVMO1));}This happends because there is more time between Enabling PVM1 and reading the register. But what is that time?
I would appreciate all help regarding this issue. Are there any additional steps I should take to make this work?
#usbSolved! Go to Solution.
- Labels:
-
USB
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-09-11 8:23 AM
In case anyone has a similar problem, here is the solution provided by ST:
- Set PVME1 bit in PWR_CR2 register to enable voltage monitoring.
- Set RT35/FT35 bit in EXTI_RTSR2/EXTI_FTSR2 register to set interrupt on rising/falling edge or both, if You need.
- Set IM35 bit in EXTI_IMR2 register to enable interrupt on EXTI line 35.
Points 2 and 3 should be generated by CubeMX but are not. That was the problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-03-24 7:04 AM
Anyone please?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-03-24 8:23 AM
This isn't an effective conduit to ST support staff and FAE, perhaps it should be, so flag FAE Participation in your Community Survey submission.. I don't work for ST and am not paid by them, I get very little community support for my projects and work.
Are there no ST support engineers in the offices near you that you can cultivate a relationship with?
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-03-24 8:28 AM
Thanks for answer,
Unfortunetaly there are none. I live in a poor country, forgotten by the world, with poor support for everything.
I will try to contact support.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-03-24 9:00 AM
Always considered Poland to be strong from a math/engineering perspective, although with the way the EU works at lot of the technical people immigrate to places where they are appreciated more. Ironically a lot end up in the UK, but I left there because the popular press, and population, seem to think engineers drive trains, install boilers or repair cars.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-03-24 9:13 AM
I can relate to your problem beoing i poland as well.
Anyways, I of course appreciate your help through all my years (in more than one company and also on ublox forums). Just dont have my own resources to pay you back.
I am just sitting here trying to make this device finally work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-03-24 9:14 AM
>> I live in a poor country, forgotten by the world
Really? I live in the same country. The support is not for free.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-03-24 9:21 AM
Maybe this strenghes our position.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-09-11 8:23 AM
In case anyone has a similar problem, here is the solution provided by ST:
- Set PVME1 bit in PWR_CR2 register to enable voltage monitoring.
- Set RT35/FT35 bit in EXTI_RTSR2/EXTI_FTSR2 register to set interrupt on rising/falling edge or both, if You need.
- Set IM35 bit in EXTI_IMR2 register to enable interrupt on EXTI line 35.
Points 2 and 3 should be generated by CubeMX but are not. That was the problem.
