2017-11-07 08:43 AM
Posted on November 07, 2017 at 17:43
Hello,
I want to use the BAM mode, and more specifically, D1/D2 in DSTANDBY, while D3 is in RUN mode. In this mode i want to have ADC3 sampling 3 channels, and transfer the results to RAM using BDMA. I am using LPTIM2 to trigger the ADC3. Using FreeRTOS....
I added the following initialization code:
__HAL_RCC_LPTIM2_CLKAM_ENABLE();
__HAL_RCC_ADC3_CLKAM_ENABLE();
__HAL_RCC_BDMA_CLKAM_ENABLE();
__HAL_RCC_D3SRAM1_CLKAM_ENABLE();
// EXTI_LINE66 is BDMA Ch0 interrupt
HAL_EXTI_D1_EventInputConfig(EXTI_LINE66, EXTI_MODE_IT | EXTI_MODE_EVT, ENABLE);
HAL_PWREx_ConfigD3Domain(PWR_D3_DOMAIN_RUN);
And this is how i put the system in BAM:
__weak void PreSleepProcessing(uint32_t *ulExpectedIdleTime)
{
/* place for user code */
SCB_CleanDCache();
HAL_PWREx_EnterSTANDBYMode(PWR_D2_DOMAIN);
HAL_PWREx_EnterSTANDBYMode(PWR_D1_DOMAIN);
*ulExpectedIdleTime = 0;
}
I do get a couple of conversion complete interrupt from DMA, but than i observe that hdma_adc3 gets nullified. The hdma_adc3 is located at adc.c module, generated by the cube. And accoriding to the map file, it resides in DTCMRAM space.
Is this the right way to use Batch Acquisition Mode? Am i missing something?
Thanks,
EVgeny
2017-12-08 08:11 AM
I was able to get in and out of BAM using ST provided examples. The thing is that the current FreeRTOS port used by ST does not support BAM at all. The problem is that we put the processor in BAM inside
configPRE_SLEEP_PROCESSING, but when it wakes up, it actually undergoes a reset process and ends up in main. All the memory and clocks are retained, but in order to pick up where we left off, we need to perform a one directional jump back into
configPRE_SLEEP_PROCESSING, to enable FreeRTOS scheduler to keep doing its thing. This would include saving and restoring the call stack, program counter etc....