Hi,
I am using a K65M180M and have a requirement to put the device in WAIT mode and the DMA must wake-up the MCU after the transfer is complete.
The MCU uses the PDB to trigger the ADC and the DMA stores the ADC results. The DMA works fine in RUN mode.
My problem is that the DMA does not wake-up the MCU once the transfer has completed. I tested the PDB and ADC interrupt and they wake-up the MCU but the DMA interrupt does not wait up the MCU. I have the SW3 pin interrupt enabled, on the TWR-K65F180M board, and it wakes the MCU it as well. I have tried using the SW3 to wake the MCU and retrigger the DMA but it still does not wake-up from WAIT mode.
I can't find any examples that use the DMA in WAIT mode and I have been through the following documents and can't see why it will not work:
KQRUG
AN4590
AN4822
AN4447
Can anyone give me advice as to why it may not wake-up?
PS. This it the procedure I use at the moment to get the MCU into WAIT mode:
SMC_SetPowerModeProtection(SMC, kSMC_AllowPowerModeAll);
// Configure the PDB and the ADC here
/* Configure DMAMUX */
DMAMUX_Init(DMAMUX0);
DMAMUX_SetSource(DMAMUX0, 0, kDmaRequestMux0ADC1 & 0xFF);
DMAMUX_EnableChannel(DMAMUX0, 0);
/* Configure EDMA one shot transfer */
EDMA_GetDefaultConfig(&userConfig);
EDMA_Init(DMA0, &userConfig);
EDMA_CreateHandle(&g_EDMA_Handle, DMA0, 0);
EDMA_SetCallback(&g_EDMA_Handle, EDMA_Callback, NULL);
EDMA_PrepareTransfer(&transferConfig, (void *)ADC16_GetDataRegisterAddress(DEMO_ADC16_BASE), sizeof(uint16_t), &AudioBuffer[ActiveBuffer], sizeof(int16_t),
sizeof(int16_t), AUDIO_BUFFER_SIZE * 2, kEDMA_PeripheralToMemory);
EDMA_SubmitTransfer(&g_EDMA_Handle, &transferConfig);
/* Wait for debug console output finished. */
while (!(kUART_TransmissionCompleteFlag & UART_GetStatusFlags((UART_Type *)BOARD_DEBUG_UART_BASEADDR)))
{
}
DbgConsole_Deinit();
/*
* Set pin for current leakage.
* Debug console RX pin: Set to pinmux to disable.
* Debug console TX pin: Don't need to change.
*/
PORT_SetPinMux(DEBUG_CONSOLE_RX_PORT, DEBUG_CONSOLE_RX_PIN, kPORT_PinDisabledOrAnalog);
// SW3 interrupt enable
PORT_SetPinInterruptConfig(APP_WAKEUP_BUTTON_PORT, APP_WAKEUP_BUTTON_GPIO_PIN, APP_WAKEUP_BUTTON_IRQ_TYPE);
// Start the DMA
EDMA_StartTransfer(&g_EDMA_Handle);
// Switch to WAIT mode
SMC_SetPowerModeWait(SMC);
MCU never wakes up unless I press SW3.
Regards,
Charles
Hi,
I have done a test with eDMA transfer example of KSDK V2.0.
I could found when eDMA finish the DMA transfer interrupt will wake up the core from WAIT mode.
Please check my attached code, I am using SW3 button of TWR-K65F180M to trigger eDMA transfer.
Wish it helps.
best regards,
Ma Hui
Hi Ma Hui,
I found the problem and it was that the ADC had triggered before the DMA was started. I was using the LowPowerMode() function to do the power mode switching from another example and the PRINTF's were taking longer than the the first ADC sample as I only started the DMA just before going to sleep.
Regards,
Charles