PIC18F45K50 and FATFS help - Page 1
Forum section: electronics / general

author: ColdKeyboard
author_rank: Contributor
timestamp: March 25, 2015, 03:58:37 am
content: I've bee trying to compile FATFS and PETITFS forPIC18F45K50with XC8 compiler but with no luck :\Only thing I got working is this poor example that must have filename size of 8 characters and all lines need to be 32 characters long :\I want to create a .txt file on the SD card (if it doesn't exist) and append data to it. Pretty much that's it.There are examples for PIC24F and PIC32 but I couldn't make them work on my mcu :\Does anyone have a suggestion how to implement fatfs and low-level IO functions or even better, have a SD card library that will work with this MCU and XC8?

author: newie
author_rank: Newbie
timestamp: March 25, 2015, 09:58:38 am
content: Have you tried microchip library for PIC18?check this library hereWWW.SecureSoftwareList/secsoftwaredownload.aspx?device=en537999&lang=en&ReturnURL=http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2680&dDocName=en537999#]http://www.microchip.com/Microchip.WWW.SecureSoftwareList/secsoftwaredownload.aspx?device=en537999&lang=en&ReturnURL=http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2680&dDocName=en537999#

author: BloodyCactus
author_rank: Frequent Contributor
timestamp: March 25, 2015, 04:25:43 pm
content: 2k ram is not a lot of space for working with a FAT filesystem (that includes your own data variables etc inside that 2k)...but still should be able to walk the FAT and open file/write it out if you strip out a lot of the cruft and stuff.

author: ColdKeyboard
author_rank: Contributor
timestamp: March 25, 2015, 04:32:33 pm
content: Quote from: newie on March 25, 2015, 09:58:38 amIn newer microchip libraries they support PIC24 and PIC32, there is no support or examples for PIC18 :\ At least I didn't find any. In older versions there are but it's for C30 and not for XC8.Quote from: BloodyCactus on March 25, 2015, 04:25:43 pm2K ram is really small footprint, are you talking about FATFS or some other FS?Does anyone have examples for PIC18 or even better working examples for PIC18F45K50 or some other similar mcu

author: BloodyCactus
author_rank: Frequent Contributor
timestamp: March 25, 2015, 07:27:16 pm
content: Quote from: ColdKeyboard on March 25, 2015, 04:32:33 pmI'm talking that your PIC18F45K50 has only 2k of RAM. thats a very small foot print to parse and walk the FAT. doable but going to be very cramped. giving the PIC18F45K50 also has very tiny tiny code space, you dont have much room for the FAT code in there.

author: sca
author_rank: Regular Contributor
timestamp: March 25, 2015, 10:50:15 pm
content: It ought to fit, looking at the memory usage table in the fatfs docs.One potential thing to look out for. I did this some years back on an 18f6550 iirc, using the hi-tech compiler pro version. It caused substantial amounts of pain, due to the compiler producing bad code for (iirc) a rather nasty double dereference inside a conditional. I ended up splitting into two separate lines of code and it worked fine. It took a *lot* of finding.I think the xc8 compiler is based on the hi-tech code so this may still be relevant.I tried to report to Microchip at the time but they wouldn't investigate without a smaller example and I didn't have time to produce one.sca