Hey Tony,
Looks like your project build setup isn't configured properly. You'd have
to give information about how files are compiled and linked.
TODO: Add a pic of my jumper pin soldering.
The Purple lines goto the ISP
/*-----------------------------------------------------------------------*/
/* Power Control (Platform dependent) */
/*-----------------------------------------------------------------------*/
/* When the target system does not support socket power control, there */
/* is nothing to do in these functions and chk_power always returns 1. */
static
void power_on (void)
{
PORTE &= ~0x80; /* Socket power ON */
for (Timer1 = 3; Timer1; ); /* Wait for 30ms */
PORTB = 0b10110101; /* Enable drivers */
DDRB = 0b11000111;
SPCR = 0b01010000; /* Initialize SPI port (Mode 0) */
SPSR = 0b00000001;
}
/* Card type flags (CardType) */ #define CT_MMC 0x01 #define CT_SD1 0x02 #define CT_SD2 0x04 #define CT_SDC (CT_SD1|CT_SD2) #define CT_BLOCK 0x08Those code changes were enough to get my project to compile. If you run into any more errors please leave a comment in the comment section at the bottom of this page.
DWORD get_fattime () {
return 0;
}
At this point my project compiled, but would not run. The reason is explained in the next section.
ISR(TIMER0_COMPA_vect) { /* should be called every 10ms */
disk_timerproc();
}
int main() {
TIMSK0 |= 1 << OCIE0A; /* enable interrupt for timer match a */
OCR0A = 78; /* 10 ms interrupt at 8MHz */
TCCR0B |= (1 << CS02) | (1 << CS00); //speed = F_CPU/1024
power_timer0_enable();
sei();
}
From the mega168 manual:
FATFS FileSystemObject;
if(f_mount(0, &FileSystemObject)!=FR_OK) {
//flag error
}
DSTATUS driveStatus = disk_initialize(0);
if(driveStatus & STA_NOINIT ||
driveStatus & STA_NODISK ||
driveStatus & STA_PROTECT
) {
//flag error.
}
/* Sometimes you may want to format the disk.
if(f_mkfs(0,0,0)!=FR_OK) {
//error
}
*/
FIL logFile;
//works
if(f_open(&logFile, "/GpsLog.txt", FA_READ | FA_WRITE | FA_OPEN_ALWAYS)!=FR_OK) {
//flag error
}
unsigned int bytesWritten;
f_write(&logFile, "New log opened!\n", 16, &bytesWritten);
//Flush the write buffer with f_sync(&logFile);
//Close and unmount.
f_close(&logFile);
f_mount(0,0);