Question
STM32F2, I2S and CS4344, I2S clock problem.
Posted on December 22, 2011 at 14:04
Hello,
I'm truing to use STM32F217 and CS4344 for my audio application. I have problem with clock initialization. /* Enable HSE */ RCC->CR |= ((uint32_t)RCC_CR_HSEON); /* Wait till HSE is ready and if Time out is reached exit */ do { HSEStatus = RCC->CR & RCC_CR_HSERDY; StartUpCounter++; } while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT)); if ((RCC->CR & RCC_CR_HSERDY) != RESET) { HSEStatus = (uint32_t)0x01; } else { HSEStatus = (uint32_t)0x00; } if (HSEStatus == (uint32_t)0x01) { /* HCLK = SYSCLK / 2*/ RCC->CFGR |= RCC_CFGR_HPRE_DIV2; /* PCLK2 = HCLK / 1*/ RCC->CFGR |= RCC_CFGR_PPRE2_DIV1; /* PCLK1 = HCLK / 2*/ RCC->CFGR |= RCC_CFGR_PPRE1_DIV2; /* Configure the main PLL */ RCC->PLLCFGR = PLL_M | (PLL_N << 6) | (((PLL_P >> 1) -1) << 16) | (RCC_PLLCFGR_PLLSRC_HSE) | (PLL_Q << 24); /* Enable the main PLL */ RCC->CR |= RCC_CR_PLLON; /* Wait till the main PLL is ready */ while((RCC->CR & RCC_CR_PLLRDY) == 0) { } /* Configure Flash prefetch, Instruction cache, Data cache and wait state */ FLASH->ACR = FLASH_ACR_PRFTEN |FLASH_ACR_ICEN |FLASH_ACR_DCEN |FLASH_ACR_LATENCY_1WS; /* Select the main PLL as system clock source */ RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW)); RCC->CFGR |= RCC_CFGR_SW_PLL; /* Wait till the main PLL is used as system clock source */ while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS ) != RCC_CFGR_SWS_PLL); { } } else { /* If HSE fails to start-up, the application will have wrong clock configuration. User can add here some code to deal with this error */ } /******************************************************************************/ /* I2S clock configuration (For devices Rev B and Y) */ /******************************************************************************/ /* PLLI2S clock used as I2S clock source */ RCC->CFGR &= ~RCC_CFGR_I2SSRC; /* Configure PLLI2S */ RCC->PLLI2SCFGR = (PLLI2S_N << 6) | (PLLI2S_R << 28); /* Enable PLLI2S */ RCC->CR |= ((uint32_t)RCC_CR_PLLI2SON); /* Wait till PLLI2S is ready */ /*while((RCC->CR & RCC_CR_PLLI2SRDY) == 0) { }*/ Program hangs on last (commented) while. Why? Regards, Marcin