Hello all!
I am currently working at a logger. I am using MSP430F2618 MCU to communicate with a SDHC and everything is fine at low speed. If I raise the speed, all commands return 0x01.
Here are some code snippets:
Clock initialization:
BCSCTL1 &= ~XT2OFF; // Activate XT2 high freq xtal
BCSCTL3 |= XT2S_2; // 3 - 16MHz crystal or resonator
BCSCTL1 = CALBC1_16MHZ;
DCOCTL = CALDCO_16MHZ;
// Wait for xtal to stabilize
do
{
IFG1 &= ~OFIFG; // Clear OSCFault flag
for (idx = 0xFF; idx > 0; idx--); // Time for flag to set
}while ((IFG1 & OFIFG)); // OSCFault flag still set?
BCSCTL2 |= SELM_2 | SELS; // MCLK = XT2 HF XTAL (safe), SMCLK = XT2
Then I initialize SPI communication. I set first the USCIB_0 registers:
UCB0CTL1 |= UCSWRST;
UCB0CTL0 |= UCMST+UCSYNC+UCCKPL+UCMSB; //3-pin, 8-bit SPI master
UCB0CTL1 |= UCSSEL_2; // SMCLK
UCB0BR0 = 0x28; // /40 => around 400Khz with 16Mhz oscillator
UCB0BR1 = 0; //
UCB0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
P3SEL |= 0x0E; // P3.3,2,1 option select
P3DIR |= 0x0B;
I am following the steps described in SD Card specifications to initialize the card. Everything goes well and then I am trying to raise the speed by setting UCB0BR0:
UCB0BR0 = 0x02; // Divide SMCLK with 2
Next step is to read first sector of the card. But here comes the problem. The response of CMD17 is 0x01.
BUT if I don't change UCB0BR0 value, everything goes well and I am successfully reading/writing on SD card.
Can anyoane help me?
Thanks!