I have previously had some issues with the SDIO that have been fixed. Recently I moved my SDIO test application into my large application and have been having a strange issue writing to the power register. I have a work around in place to get the power register set, but it seems to be causing issues further along such as not being able to enable the clock either.
Here is a snippit of the function that initializes my SDIO...
SD_Error DIL_SDIO_Power_On ( void )
SD_Error errorstatus = SD_OK;
uint32_t response = 0;
uint32_t count = 0;
uint32_t validvoltage = 0;
uint32_t SDType = SD_STD_CAPACITY;
/* Power ON Sequence -----------------------------------------------------*/
/* Configure the SDIO peripheral */
/* SDIOCLK = HCLK, SDIO_CK = HCLK/(2 + SDIO_INIT_CLK_DIV) */
/* on STM32F2xx devices, SDIOCLK is fixed to 48MHz */
/* SDIO_CK for initialization should not exceed 400 KHz */
SDIO_InitStructure.SDIO_ClockDiv = SDIO_INIT_CLK_DIV;
SDIO_InitStructure.SDIO_ClockEdge = SDIO_ClockEdge_Rising;
SDIO_InitStructure.SDIO_ClockBypass = SDIO_ClockBypass_Disable;
SDIO_InitStructure.SDIO_ClockPowerSave = SDIO_ClockPowerSave_Disable;
SDIO_InitStructure.SDIO_BusWide = SDIO_BusWide_1b;
SDIO_InitStructure.SDIO_HardwareFlowControl = SDIO_HardwareFlowControl_Disable;
SDIO_Init ( &SDIO_InitStructure );
/* Set Power State to ON */
SDIO_SetPowerState ( SDIO_PowerState_ON );
/* Enable SDIO Clock */
SDIO_ClockCmd ( ENABLE );
SDIO->POWER &= PWR_PWRCTRL_MASK;
SDIO->POWER |= SDIO_PowerState;
The problem is the register is not being set.
If I comment out the first line in SetPowerState ( SDIO->POWER &= PWR_PWRCTRL_MASK;) the register does get set.
How important is this line? It is part of the stm32f2xx library so I am wary about commenting it out. ( #define PWR_PWRCTRL_MASK ((uint32_t)0xFFFFFFFC) )
From what I understand it is just clearing out the first 2 bits of the register before writing to it. In the reference manual it shows all other bits as reserved always reading 0. So why is it important to preserve these bits?
Does this seem weird to anyone?
Has anyone ever seen this issue?
The Problem is worse than I thought. Something must be going wrong prior to setting the power state and the clock enable. as neither are happening. The code is identical to what i have had previously. I am currently lost and will update if I find a solution.