cancel
Showing results for 
Search instead for 
Did you mean: 

LPBAM Scenario usage multiple analog watchdogs

sleon.1
Associate II

I've trying for days to get the LPBAM tool to work. The TempSense example project is similar to what i'm trying to do. I'd like to immediately stop2 on power up and continually sample 3 channels. The first condition i'm waiting for is IN1 > 1100, so i setup a AWD1 no interrupt with a LPTIM period change triggered on rising edge ADC4 AWD1 so i can see it on the scope (no debug in stop2 or at least i haven't figured it out). Then i'd like to switch the analog watchdog to IN2 (haven't been successful reusing AWD1 since i'm done with it nor using AWD2) and here i'm looking for a signal around the midpoint of the ADC (sine wave zero crossing). From what i've read, the watchdog range won't work backwards (trigger inside a range not outside a range) so I set this up as two watchdogs, first going up out of the lower half and then the second coming down out of the upper half (close enough to a zero crossing for me). After these signals have all occurred in that order, i'd like to DMA capture 512 samples of all channels and then wake up to process the data. This all seems possible on paper and would be really powerful if it did, but not apparently in practice. I'm not sure if i need to be clearing watchdog flags somehow and thats why it won't progress to the next trigger or not.

static void MX_Threshold1_Conversion_Q_Build(void)
{
  /* LPBAM build variable */
  LPBAM_DMAListInfo_t pDMAListInfo_ADC = {0};
  LPBAM_ADC_DataAdvConf_t pConvData_ADC = {0};
 
  /**
    * Threshold1_Conversion queue ConvData_Threshold1 build
    */
  pDMAListInfo_ADC.QueueType = LPBAM_LINEAR_ADDRESSING_Q;
  pDMAListInfo_ADC.pInstance = LPDMA1;
  pConvData_ADC.DMAContinuousRequests = DISABLE;
  pConvData_ADC.Size = 512;
  pConvData_ADC.pData = (uint32_t*)&Threshold1_Data_Buffer[0];
  if (ADV_LPBAM_ADC_Conversion_SetDataQ(ADC4, &pDMAListInfo_ADC, &pConvData_ADC, &Threshold1_Conversion_Q_ConvData_Threshold1_Desc, &Threshold1_Conversion_Q) != LPBAM_OK)
  {
    Error_Handler();
  }
 
  /**
    * Set circular mode
    */
  if (ADV_LPBAM_Q_SetCircularMode(&Threshold1_Conversion_Q_ConvData_Threshold1_Desc, LPBAM_ADC_CONVERSION_DATAQ_DATA_NODE, &Threshold1_Conversion_Q) != LPBAM_OK)
  {
    Error_Handler();
  }
}
 
/**
  * @brief  TempSens application MultiThres scenario Thresholdx_Config queue build
  * @param  None
  * @retval None
  */
static void MX_Thresholdx_Config_Q_Build(void)
{
  /* LPBAM build variable */
  LPBAM_DMAListInfo_t pDMAListInfo_LPDMA = {0};
  LPBAM_DMA_StartFullAdvConf_t pStartFull_LPDMA = {0};
  LPBAM_DMAListInfo_t pDMAListInfo_LPTIM = {0};
  LPBAM_LPTIM_PWMFullAdvConf_t pPWMFull_LPTIM = {0};
  LPBAM_COMMON_TrigAdvConf_t pTrigConfig_LPTIM = {0};
  LPBAM_DMAListInfo_t pDMAListInfo_ADC = {0};
  LPBAM_ADC_AWDGFullAdvConf_t pAWDGFull_ADC = {0};
  LPBAM_COMMON_TrigAdvConf_t pTrigConfig_ADC = {0};
 
  /**
    * Thresholdx_Config queue Threshold1_Q_Start1 build
    */
  pDMAListInfo_LPDMA.QueueType = LPBAM_LINEAR_ADDRESSING_Q;
  pDMAListInfo_LPDMA.pInstance = LPDMA1;
  pStartFull_LPDMA.WakeupIT = LPBAM_DMA_IT_NONE;
  pStartFull_LPDMA.HeadQAddress = (uint32_t)Threshold1_Conversion_Q.Head;
  if (ADV_LPBAM_DMA_Start_SetFullQ(LPDMA1_Channel0, &pDMAListInfo_LPDMA, &pStartFull_LPDMA, &Thresholdx_Config_Q_Threshold1_Q_Start1_Desc, &Thresholdx_Config_Q) != LPBAM_OK)
  {
    Error_Handler();
  }
 
  /**
    * Thresholdx_Config queue PWM_1 build
    */
  pDMAListInfo_LPTIM.QueueType = LPBAM_LINEAR_ADDRESSING_Q;
  pDMAListInfo_LPTIM.pInstance = LPDMA1;
  pPWMFull_LPTIM.UpdatePeriod = ENABLE;
  pPWMFull_LPTIM.PeriodValue = 16;
  pPWMFull_LPTIM.UpdatePulse = ENABLE;
  pPWMFull_LPTIM.PulseValue = 8;
  pPWMFull_LPTIM.UpdateRepetition = DISABLE;
  pPWMFull_LPTIM.RepetitionValue = 0;
  if (ADV_LPBAM_LPTIM_PWM_SetFullQ(LPTIM1, LPBAM_LPTIM_CHANNEL_1, &pDMAListInfo_LPTIM, &pPWMFull_LPTIM, &Thresholdx_Config_Q_PWM_1_Desc, &Thresholdx_Config_Q) != LPBAM_OK)
  {
    Error_Handler();
  }
  pTrigConfig_LPTIM.TriggerConfig.TriggerMode = LPBAM_DMA_TRIGM_BLOCK_TRANSFER;
  pTrigConfig_LPTIM.TriggerConfig.TriggerPolarity = LPBAM_DMA_TRIG_POLARITY_RISING;
  pTrigConfig_LPTIM.TriggerConfig.TriggerSelection = LPBAM_LPDMA1_TRIGGER_ADC4_AWD1;
  if (ADV_LPBAM_Q_SetTriggerConfig(&pTrigConfig_LPTIM, LPBAM_LPTIM_PWM_FULLQ_CONFIG_NODE, &Thresholdx_Config_Q_PWM_1_Desc) != LPBAM_OK)
  {
    Error_Handler();
  }
 
  /**
    * Thresholdx_Config queue Analog_Watchdog_2 build
    */
  pDMAListInfo_ADC.QueueType = LPBAM_LINEAR_ADDRESSING_Q;
  pDMAListInfo_ADC.pInstance = LPDMA1;
  pAWDGFull_ADC.AnalogWDGConfig[0U].WatchdogNumber = LPBAM_ADC_ANALOGWATCHDOG_1;
  pAWDGFull_ADC.AnalogWDGConfig[0U].WatchdogMode = LPBAM_ADC_ANALOGWATCHDOG_SINGLE_REG;
  pAWDGFull_ADC.AnalogWDGConfig[0U].Channel = LPBAM_ADC_CHANNEL_2;
  pAWDGFull_ADC.AnalogWDGConfig[0U].ITMode = DISABLE;
  pAWDGFull_ADC.AnalogWDGConfig[0U].LowThreshold = 0;
  pAWDGFull_ADC.AnalogWDGConfig[0U].HighThreshold = 2047;
  if (ADV_LPBAM_ADC_AnalogWDGConfig_SetFullQ(ADC4, &pDMAListInfo_ADC, &pAWDGFull_ADC, &Thresholdx_Config_Q_Analog_Watchdog_2_Desc, &Thresholdx_Config_Q) != LPBAM_OK)
  {
    Error_Handler();
  }
 
  /**
    * Thresholdx_Config queue Threshold1_Q_Start2 build
    */
  if (ADV_LPBAM_DMA_Start_SetFullQ(LPDMA1_Channel0, &pDMAListInfo_LPDMA, &pStartFull_LPDMA, &Thresholdx_Config_Q_Threshold1_Q_Start2_Desc, &Thresholdx_Config_Q) != LPBAM_OK)
  {
    Error_Handler();
  }
 
  /**
    * Thresholdx_Config queue PWM_2 build
    */
  pPWMFull_LPTIM.PeriodValue = 8;
  pPWMFull_LPTIM.PulseValue = 4;
  if (ADV_LPBAM_LPTIM_PWM_SetFullQ(LPTIM1, LPBAM_LPTIM_CHANNEL_1, &pDMAListInfo_LPTIM, &pPWMFull_LPTIM, &Thresholdx_Config_Q_PWM_2_Desc, &Thresholdx_Config_Q) != LPBAM_OK)
  {
    Error_Handler();
  }
  if (ADV_LPBAM_Q_SetTriggerConfig(&pTrigConfig_LPTIM, LPBAM_LPTIM_PWM_FULLQ_CONFIG_NODE, &Thresholdx_Config_Q_PWM_2_Desc) != LPBAM_OK)
  {
    Error_Handler();
  }
 
  /**
    * Thresholdx_Config queue Analog_Watchdog_1 build
    */
  pAWDGFull_ADC.AnalogWDGConfig[0U].ITMode = ENABLE;
  pAWDGFull_ADC.AnalogWDGConfig[0U].LowThreshold = 2048;
  pAWDGFull_ADC.AnalogWDGConfig[0U].HighThreshold = 4095;
  if (ADV_LPBAM_ADC_AnalogWDGConfig_SetFullQ(ADC4, &pDMAListInfo_ADC, &pAWDGFull_ADC, &Thresholdx_Config_Q_Analog_Watchdog_1_Desc, &Thresholdx_Config_Q) != LPBAM_OK)
  {
    Error_Handler();
  }
  pTrigConfig_ADC.TriggerConfig.TriggerMode = LPBAM_DMA_TRIGM_BLOCK_TRANSFER;
  pTrigConfig_ADC.TriggerConfig.TriggerPolarity = LPBAM_DMA_TRIG_POLARITY_FALLING;
  pTrigConfig_ADC.TriggerConfig.TriggerSelection = LPBAM_LPDMA1_TRIGGER_ADC4_AWD1;
  if (ADV_LPBAM_Q_SetTriggerConfig(&pTrigConfig_ADC, LPBAM_ADC_ANALOGWDG_FULLQ_CONFIG_NODE, &Thresholdx_Config_Q_Analog_Watchdog_1_Desc) != LPBAM_OK)
  {
    Error_Handler();
  }
 
  /**
    * Thresholdx_Config queue Threshold2_Q_Start build
    */
  if (ADV_LPBAM_DMA_Start_SetFullQ(LPDMA1_Channel0, &pDMAListInfo_LPDMA, &pStartFull_LPDMA, &Thresholdx_Config_Q_Threshold2_Q_Start_Desc, &Thresholdx_Config_Q) != LPBAM_OK)
  {
    Error_Handler();
  }
 
}

Any help would be greatly appreciated.


_legacyfs_online_stmicro_images_0693W00000bkVWSQA2.png

5 REPLIES 5

Which STM32?

> I've trying for days to get the LPBAM tool to work.

What is LPBAM tool?

JW

Hi @Community member​ 

LPBAM tools is in cubeMx .He is using STM32U5.

Regards

Diane

Thanks, Diane, for the explanation.

Jan

@Diane POMABIA​ 

The LPBAM feature is only available in the STM32U5 series, it allows peripherals to be autonomous in stop2 mode and has clock request capability and DMA transfers while the CPU is offloaded (smart run domain).

also, it optimizes power consumption

The following article gives an overview and an example using LPBAM

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

I wonder if anyone has used it before and can provide meaningful answers to my questions.