free 8051 Microcontroller Projects AVR PIC Microcontroller Projects Tutorials Ebooks Libraries, interfacing tutorials, lcd tutorial, stepper motor, dc motor 8051 assembly language programming electronics and communication ECE CSE pdf ebooks library BE final year project ideas Embedded systems
Chan's auto_mount() function decides if the card is write protected by looking at the return value from your disk_initialize() function.
Notice the parameters that are passed to auto_mount()? The last parameter is called "chk_wp" - this is a flag to check for write_protection. If this value is set to 1, then the last line in your code above will be executed. If it is zero, then it won't.
When you scan through all of the calls to auto_mount(), you will find that some have this set to 1, and some don't. The ones that have it set to 1 are the functions that want to write to the card, like making directories, making files, formatting the card, etc...
But the reason why you are getting the FR_WRITE_PROTECTED message is because the "stat" variable, which was set within your disk_initialize() function, has the STA_PROTECT bit set.
Try looking in the disk_initialize() function. This is where you problem lies...
Hope this helps,
-Dave "Basic research is what I am doing when I don't know what I am doing"
The disk_initialize() is the same as the example that is given here, and the SD_Init returns 0 as it should. Later I tried to send the command CLR_WRITE_PROT before the f_open, this as solved the problem... Now i have another one, again in auto_mount(). When it search for the FAT partition on the drive: fmt = check_fs(bootsect = 0); the check_fs returns 2 (fm=2) in the second condition:
if (LD_WORD(&fs->win[BS_55AA]) != 0xAA55) /* Check record signature */ return 2;
With fm=2 the auto_mout returns :
if (fmt || LD_WORD(&fs->win[BPB_BytsPerSec]) != 512U) /* No valid FAT patition is found */ return FR_NO_FILESYSTEM;
Do you think that there is a problem with the SD card? I have formatted the card in FAT and later i tried with FAT32. the same error happens.
The disk_initialize() is the same as the example that is given here, and the SD_Init returns 0 as it should. Later I tried to send the command CLR_WRITE_PROT before the f_open, this as solved the problem... Now i have another one, again in auto_mount(). When it search for the FAT partition on the drive: fmt = check_fs(bootsect = 0); the check_fs returns 2 (fm=2) in the second condition:
if (LD_WORD(&fs->win[BS_55AA]) != 0xAA55) /* Check record signature */ return 2;
With fm=2 the auto_mout returns :
if (fmt || LD_WORD(&fs->win[BPB_BytsPerSec]) != 512U) /* No valid FAT patition is found */ return FR_NO_FILESYSTEM;
Do you think that there is a problem with the SD card? I have formatted the card in FAT and later i tried with FAT32. the same error happens.
Using that func isn't the same as the format of windows?? because i have formatted in FAT16 and 32 and still didn't work. It is possible that the 2 card that i have, have problems?? The 2 card are: 2Gb, Kingston and it is recognized as a type2. 1Gb, ??? and it is recognized as a type 1.
can you try with a lower size card? 512MB or 256MB? www.rickeyworld.info If you feel satisfied with the user's forum reply please click on the thank button.
hi, is it compulsary to make CHIP SELECT CS (BAR) = 1 aftr WRITE wr(bar ) and READ rd(bar) hv been changed to trigger conversion and to read data respectively ??
8051 Microcontroller Projects 8051 AVR tutorials PIC microcontroller, 8051 assembly language programming electronics and communication ECE CSE pdf ebooks library BE final year project ideas Embedded systems