Continue to Site

Welcome to

Welcome to our site! is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

FatFs on dsPIC33FJ128GP802

Not open for further replies.


Newbie level 4
Jul 3, 2011
Reaction score
Trophy points
Activity points
Good day to you people.
I'm developing a project where I need to store audio samples to an SD card in .wav format, the audio data is 16 bits resolution, stereo, with a sampling rate of 48khz, i'm using a dsPIC33FJ128GP802 because of it's DCI peripheral(to communicate with audio ADC) and its audio DAC, at the present time I am trying to write the samples to the sd card, i'm using microchip MDD library but i'm finding it too slow for my application, I need almost 200 Kbyte/sec throughput rate, so I will now use ChaN's FatFS library which I've read is a lot faster, I'm trying to port the FatFs PIC24F sample I found on ChaN's website to my dsPIC33F, I changed the Microcontroller, the working pins and found out the registers are almost the same, but when I try to compile de project, an error message: "ff.o: Link Error: Could not allocate section .nbss, size = 264 bytes, attributes = bss near" keeps popping out, does anybody knows what this means? has anyone ported the sample project to a dsPIC33F? I also erased the main.c code except for the get_fattime function so I could get a little test code of my own.
Any help would be appreciated and thank you for your time.

I think you can find documentation on the C30 linker/compiler documentation.

hope this helps!
Apart from the compiler problem, the secret to achieve high sustained write data rates on flash media is writing multiple sectors at once, according to the internal organisation of the flash memory. Otherwise the internal flash controller will need to write huge sectors for a few data.

ok, according to what I've read a sector is 512 bytes right? so you say I should write like 4096 bytes of data in one command and it should write faster?

To increase the throughput, you should take care, that a CMD25 WRITE_MULTIPLE_BLOCK is used instead of CMD24 WRITE_BLOCK.
I haven't read a lot about the low level functions the MDD library uses so to say, does Fsfwrite function uses CMD24 WRITE_BLOCK by default? should I change the function so it uses CMD25 WRITE_MULTIPLE_BLOCK or should I use CMD25 directly instead? Do you think I can get the 200Kbyte/sec throughput by using WRITE_MULTIPLE_BLOCK command? Thank you for your time.

I must confess, that I didn't actually try with SD cards. But I did extensive test with compact flash cards, that have very similar command sets. There's an application note from SanDisk about write optimization with some impressive throughput numbers. Because the basic problem exists for all kind of NAND flash media, I'm rather sure that it applies for SD and MMC cards as well. I was able to improve the throughput considerably by changing an embedded memory card driver to multi sector writes. Of course I don't know about the architecture of your flash driver. A simple driver, that tries to minimize it's RAM footprint may want to write only single sectors to simplify the FAT and directory housekeeping. In this case, extensive modification smay be required to implement multi-sector writes.


  • AppNoteCFHostv1.1.pdf
    254.3 KB · Views: 50

ok, seems I have a lot to do to get multi_block_write on MDD library :), do you know if ChaN's FatFs library uses multi_block_write?

Not open for further replies.

Part and Inventory Search

Welcome to