v5 Beta FAT16 component SDHC

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

User avatar
Nico595
Posts: 84
Joined: Mon Jan 23, 2012 6:46 pm
Location: France
Has thanked: 12 times
Been thanked: 10 times
Contact:

Re: v5 Beta FAT16 component SDHC

Post by Nico595 »

Hi Ben,

With the last version, Init_Fat is perfect without my code.

Thank you :wink:

User avatar
Nico595
Posts: 84
Joined: Mon Jan 23, 2012 6:46 pm
Location: France
Has thanked: 12 times
Been thanked: 10 times
Contact:

Re: v5 Beta FAT16 component SDHC

Post by Nico595 »

A small bug after Init Fat in MX_Init_Card on ARM, after SPI_Master_Init -> PA21 is high

Code: Select all

	MX_UINT8 RetVal, SD_version;
	MX_SINT16 i;

	FC_CAL_Bit_High_DDR (%a_MX_SPI_FAT_CS_PORT, %a_MX_SPI_FAT_CS_TRIS, %a_MX_SPI_FAT_CS_PIN);	// Chip Select pin is disabled

	//Init SPI
	%a_SPI_Master_Init();							//Call initialise function

AT91C_BASE_PIOA->PIO_CODR = AT91C_PIO_PA21; // Set pin state to 'low'


	delay_ms(50);														//Wait for card to power up

	for(i = 0; i < 10; i++)												//Start CARD in SPI mode
	{
		%a_SPI_Master_Byte(0xFF);					//Send 10*8=80 clock pulses
	}
I've not found other solution this that:
AT91C_BASE_PIOA->PIO_CODR = AT91C_PIO_PA21;

User avatar
Nico595
Posts: 84
Joined: Mon Jan 23, 2012 6:46 pm
Location: France
Has thanked: 12 times
Been thanked: 10 times
Contact:

Re: v5 Beta FAT16 component SDHC

Post by Nico595 »

Hi,

I paste topic FAT Freeze on Move_To_Next_File_Sector(1) here :)


I have a problem with FAT component, when I write, Move_To_Next_File_Sector freeze system

Problem is in this while in MX_Add_Sector_To_File, time is very important, > 2s.

Code: Select all

//Boucle tres longue sur Carte SDHC
	while (fat_pointer > 0)								//Scan FAT for free entry
	{
		idx_fat = (MX_UINT32) idx_fat + 1;					//Increment FAT address - Start at address 2
		if(idx_fat == %a_FATS_PER_SECT)					//If at the end of the FAT sector
		{
			fat_address = fat_address + 1;
			MX_Get_Buffer(fat_address);					//Read next FAT sector
			idx_fat = 0;
		}

		Temp32.AsByte[0] = Read_Byte_From_Buffer(idx_fat * %a_SECT_ADDR_LEN);			//Extract data %a_mx_cluster address
		Temp32.AsByte[1] = Read_Byte_From_Buffer((idx_fat * %a_SECT_ADDR_LEN) + 1);
		Temp32.AsByte[2] = 0;
		Temp32.AsByte[3] = 0;

		#if (%a_FAT_TYPE == 1 || %a_FAT_TYPE == 2)
			if (%a_mx_fat_system == 1)
			{
				Temp32.AsByte[2] = Read_Byte_From_Buffer((idx_fat * %a_SECT_ADDR_LEN) + 2);
				Temp32.AsByte[3] = Read_Byte_From_Buffer((idx_fat * %a_SECT_ADDR_LEN) + 3);
			}
		#endif

		fat_pointer = Temp32.AsLong;
	}

I think here:

Code: Select all

if(idx_fat == %a_FATS_PER_SECT)					//If at the end of the FAT sector
		{
			fat_address = fat_address + 1;
			MX_Get_Buffer(fat_address);					//Read next FAT sector
			idx_fat = 0;
		}
Thanks for your advices.

EDIT: This important time exist only with SDHC Card, with 2GO Card, Move_To_Next_File_Sector(1) is fast

May be a small work for you Ben ;)

Post Reply