Oops! It appears that you have disabled your Javascript. In order for you to see this page as it is meant to appear, we ask that you please re-enable your Javascript!

Reply To: How to use FatFs library in MPLAB XC8 without MPLAB Code Configurater?

Home Forums MPLAB XC8 Tutorial Discussions How to use FatFs library in MPLAB XC8 without MPLAB Code Configurater? Reply To: How to use FatFs library in MPLAB XC8 without MPLAB Code Configurater?

#2529

Karalan
Participant

I just want to write and read in SD Card. Now I trying with the code which is example code in your tutorial.

main.c file:

#include “newxc8_header.h”
#include “ff.h”

void main(void) {

ADCON1=0x0F;
OSCCON=0x76;
// Open the file “test.txt” and Write “Hello world!”
FATFS FatFs; // FatFs work area needed for each volume
FIL Fil; // File object needed for each open file
UINT bw;
if (f_mount(&FatFs, “”, 1) == FR_OK) { // Mount SD
if (f_open(&Fil, “test.txt”, FA_OPEN_ALWAYS | FA_READ | FA_WRITE) == FR_OK) { // Open or create a file
f_write(&Fil, “Hello world!\r\n”, 14, &bw); // Write data to test.txt file
}
}
}