estoy pensando en que se puede resolver algo parceido a esto...
void RecMic(void) {
unsigned int* data;
unsigned int i;
FSFILE *logFile;
BOOL initResults;
WORD_VAL ADCResult;
BYTE printData[6];
WORD_VAL w;
//set the data pointer for the FSfwrite function
data = &i;
initResults = FSInit();
//initialize the A/D
mInitMIC();
//Set up the LED as output
mInitAllLEDs();
//Set the push button input
mInitSwitch2();
//The log file is not open so let's make sure the pointer is NULLed out
logFile = NULL;
while (TRUE) {
if (initResults == TRUE) {
if (sw2 == 1) {
if (logFile != NULL) {
// Get an ADC sample
mInitMIC();
ADCON0bits.GO = 1;// Start AD conversion
while (ADCON0bits.NOT_DONE); // Wait for conversion
w.v[0] = ADRESL;
sample = ADPCMENcoder((w.v[0] >> 4)&0x0f, &state);
// Get an ADC sample
mInitMIC();
ADCON0bits.GO = 1; // Start AD conversion
while (ADCON0bits.NOT_DONE); // Wait for conversion
w.v[1] = ADRESH;
sample = ADPCMEncoder((w.v[1] >> 8)&0x0f, &state);
sprintf((char*) &printData[0], "%d\r\n", sample.Val);
FSfwrite((const void*) &printData[0], 1, sizeof (printData), logFile);
} else {
#if defined(__18CXX)
logFile = FSfopenpgm("log.csv", "w");
#endif
}
mLED_1_On();
} else {
if (logFile != NULL) {
FSfclose(logFile);
logFile = NULL;
}
mLED_1_Off();
}
} else {
if (MDD_SDSPI_MediaDetect() == TRUE) {
initResults = FSInit();
}
}
} //end while
#if !defined(__18CXX)
return 0;
#endif
}
Estoy utilizando un 18F8722, 4Mhz Xtal, SD Card atached to the SPI ports, the Microchip Memory Disk Drive File System.
Que piensan... dejen sus comentarios...
Saludos.....