2013-08-02 10:18 AM
I have the PORT board , with STM32F207ZG , I have written my own SD library , since i did not feel good using the built in library , ...... the library i wrote is working correctly as it should be , and i wrote n read from the card correctly , but I just have a problem with clocking .... this is the configurations i have in the main ()
{ uint32_t temp; temp=0; RCC->CFGR=0x00000000; RCC->CFGR|=(uint32_t)(0x09<<4);//AHB Prescalar of 4 //RCC->CFGR|=(0x06<<13); //APB2 prescalar (if i uncomment this line , card wont initialize) // // temp|=(0x08<<24); // PLL Division factor for SDIO (PLLQ) = 8 temp|=0x08; // Main Division Factor for PLL input (PLLM) = 8 temp|=(0xC0<<6); // Main PLL multiplication factor (PLLN) = 192 temp|=(3<<16); // Main Division Factor for PLL output (PLLP) = 8 RCC->PLLCFGR=temp; RCC->CR|=(1<<24); while(!(RCC->CR & (1<<25))); // Waiting for PLL output to be ready //RCC->CFGR|=(1<<1); // PLL is the system clock (if i uncomment this line , the card wont initialize , idk y ) // // . . . } and on the SD_CARD_INIT() { SDIO->CLKCR=0x00000000; SDIO->CLKCR|=120; // Clock division factor but it has no meaning as long as bypass is enabled SDIO->CLKCR|=(1<<10); //By_pass enabled (if i comment this line , it wont work) SDIO->CLKCR|=(1<<8); // Clock enabled SDIO->POWER=0x00000003; // // Initialization Sequence // .. .. } so the problem now is that i can not use the 96 MHz for the core processor or the card will fail initialization , even if i make sure that the clock on the APB2 domain is less than 60 MHz as the manual says , ..... but the other interesting fact is that according to these configurations , the card initialization is done via 48 MHZ clock , rather than 400KHZ or less ???!!!!!!!!! This is urgent guys , cuz i really started to doubt this chip .2013-08-02 12:13 PM
I'm not sure I want to wade through this mess. If you don't run from the PLL, then the process is going to be grinding at 8 or 16 MHz via the HSE or HSI, and the APBx a bunch slower than that.
I'm not sure running an APB at 1-2 MHz is compatible with running the SDIO at 48 MHz. Start by fixing your clocking problems, and verify what clocks you've got by exporting them via the MCOx pins and viewing them on a scope.2013-08-02 07:01 PM
first thanks clive for ur reply ,..........well i do not really have a scope right now , ............but i can tell u that im sure i can run the Core on 96MHZ (through the Delay function) , so up to the PLL output , i can tell u that everything is going ok , ......... about the APB2 domain , and its Compatibility with SDIO , all the sheet tells is that the clock on the APB2 bus should not be more than 60 MHz and it should also follow that condition APB2 clock >= (3/8) SDIO_CLK .
It would be nice if u worked with this interface , so u can tell me how u clocked it. thanks in advance.2013-08-02 07:24 PM
Can you provide a cite for this ''PORT'' board, I'm not familiar with it.
Is there a reason you can't test the SDIO using the example code in the library? I'm not terribly keen on digging through register level code to fix an interface I know works with the examples. Is there a reason to be clocking at 96 MHz instead of 120 MHz? The SDIO peripheral requires the PLL (Q tap) to be functioning, if the PLL isn't running it won't work. It looks like you have the PLL running, just not using it. You definitely don't want the bypass when enabling the card, the divider permits you to run it at about 400 KHz for initialization, and about 24 MHz when operating. While it's possible to run some cards at 48 MHz, or higher, I'd start with something slower, especially for full size cards. Does your board use MicroSD cards? What's the spec on the cards you're testing right now?2013-08-02 07:43 PM
2013-08-02 08:03 PM
The clocks setting you had earlier were totally broken.
PLLP should be 2, gets 192 MHZ to 96 MHz PLLQ should be 4, gets 192 MHz to 48 MHz (SDIO/USB) [was 8] PLLM should be 25 if you have an external 25 MHz source [was 8] AHB should be DIV1 [was div 4] APB2 should be DIV2 [was div 8] APB1 should be DIV4 [was undefined] The example code for SDIO is here: STM32F2xx_StdPeriph_Lib_V1.1.0\Project\STM32F2xx_StdPeriph_Examples\SDIO\uSDCard I'll have to work through your other info.2013-08-02 08:10 PM
no it was not broken clive cuz i was working on the HSI not HSE . ...... any way like i told u , now im sure that nothing else will be done to the RCC Registers ...... i guess.
2013-08-03 06:40 AM
Hey clive , i solved the problem ...... well the problem was that in my Send_Command function , i wrote to the CMD register two times successively , and according to the manual , u should wait for like 3 SDIO CLK and 2 APB2 clk , thats why it worked on low frequencies of the Core ..... now i put a little delay between these two lines and the problem was solved . Thx alot for ur efforts bro .