It is currently 22 Oct 2018 11:06

All times are UTC + 1 hour




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: 25 Dec 2017 15:08 
Offline

Joined: 25 Dec 2017 14:46
Posts: 3
hello every one

i would initialize a 4GB HCSD card by STM32F030K6T6 and Multi Media Card library of mikroC PRO for ARM, but have no response from HCSD card.i think ,the MMC/SD FAT16 boot sector of HCSD card is not be detected by MCU and "1" be returned by "Mmc_Fat_Init()" function.it would be appreciated if guide me.my code is following:

//********************************************************************//


sbit Mmc_Chip_Select at GPIOB_ODR.B7;

char filename[ ]="ALI.TXT";
char file_contents[ ]="ali";
char test ;
int k;
void main()
{
GPIO_Clk_Enable(&GPIOB_BASE);
GPIO_Set_Pin_Mode(&GPIOB_BASE, _GPIO_PIN_0, _GPIO_CFG_MODE_OUTPUT);
GPIO_Set_Pin_Mode(&GPIOB_BASE, _GPIO_PIN_1, _GPIO_CFG_MODE_OUTPUT);
SPI1_Init_Advanced(_SPI_FPCLK_DIV32, _SPI_MASTER | _SPI_8_BIT |
_SPI_CLK_IDLE_LOW | _SPI_FIRST_CLK_EDGE_TRANSITION |
_SPI_MSB_FIRST | _SPI_SS_DISABLE | _SPI_SSM_ENABLE | _SPI_SSI_1,
&_GPIO_MODULE_SPI1_PA567);
GPIOB_BSRRbits.BS0=1;
GPIOB_BSRRbits.BS1=1;
Vdelay_ms(1000);
Vdelay_ms(1000);
Vdelay_ms(1000);
Vdelay_ms(1000);
Vdelay_ms(1000);
Vdelay_ms(1000);
Vdelay_ms(1000);
Vdelay_ms(1000);
do
{
test=Mmc_Fat_Init();
if(test==1)
{
Vdelay_ms(1000);
GPIOB_BSRRbits.BR0=1;
GPIOB_BSRRbits.BR1=1;
}
else if(test==255)
{
Vdelay_ms(1000);
GPIOB_BSRRbits.BS0=1;
GPIOB_BSRRbits.BS1=1;
}
}
while(test!=0);
GPIOB_BSRRbits.BS0=1;
GPIOB_BSRRbits.BS1=1;
SPI1_Init_Advanced(_SPI_FPCLK_DIV2, _SPI_MASTER | _SPI_8_BIT |
_SPI_CLK_IDLE_LOW | _SPI_FIRST_CLK_EDGE_TRANSITION |
_SPI_MSB_FIRST | _SPI_SS_DISABLE | _SPI_SSM_ENABLE | _SPI_SSI_1,
&_GPIO_MODULE_SPI1_PA567);

Mmc_Fat_Set_File_Date(2017,12,21,11,9,0); // Set file date & time info
Mmc_Fat_Assign(&filename, 0xA0); // Find existing file or create a new one
Mmc_Fat_Rewrite(); // To clear file and start with new data
Mmc_Fat_Write(file_contents,sizeof(file_contents));
while(1)
{

}
}


thanks and best regards


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: