FATFS f_read problem

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well here we go: MP3 player, winavr 20090303, PN, 3.3V system using 2GB SD, vs1011E and xmega16A4, FATFS 7e. Read only.

inits, mounts, and f_open correctly.


#define   sec_2_buf   2

BYTE Buff[512];			/* Working buffer */
BYTE mp3_buf[ 512*sec_2_buf ];   /* file copy buffer */

.
.
.

void   main( void)
{

    FATFS fs[1] ;         /* Work area (file system object) for logical drives */
    DIR dir;         /* file objects */
    FIL fsrc;
	
    FRESULT res;         /* FatFs function common result code */
    UINT br, bw;         /* File R/W count */

PORTB_PIN3CTRL = PORT_OPC_PULLUP_gc;  // EN pullup for sd cd
PORTB.DIRSET = PIN1_bm; //SEtup debug LED

while( sd_cd ); //set_led; //SD card cd pin, PB7
_delay_ms(250);  // Debounce the sd cd contact.

RTC_init();
init_spiC();
VS_init();
sei();
play_ptr = mp3_buf;
driveStatus1 = disk_initialize((BYTE)0); // Must be B 4 f_mount
 
if(driveStatus1 & STA_NOINIT ||
   driveStatus1 & STA_NODISK ||
   driveStatus1 & STA_PROTECT
   ) {
  asm("nop");//flag error.
 }
 
else  asm("nop");//set_led; // INITS !!!

res = f_mount((BYTE)0, &fs[0]);
fast_clk(); // Change sys_clk via PLL ( to 16 MHz )

res = f_open(&fsrc, "Hrt_war.mp3", FA_OPEN_EXISTING | FA_READ );//FR_OK 
//if ( res == FR_OK ) set_led;

res = f_read(&fsrc, mp3_buf ,sizeof(mp3_buf) , &br ); 
if ( res == FR_OK ) set_led;
// hangs in here 'freaks

Code section below is from ff.c --> f_read line 1797. Executes code all the way into if (cc){ }, but NEVER executes ANYTHING inside the if statement!!!??

if (cc) {	// gets here							/* Read maximum contiguous sectors directly */

1) Studio 4.18 build 716 (SP3)
2) WinAvr 20100110
3) PN, all on Doze XP... For Now
A) Avr Dragon ver. 1
B) Avr MKII ISP, 2009 model
C) MKII JTAGICE ver. 1

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Two things:

1) you already have a thread about using FatFs here:

https://www.avrfreaks.net/index.p...

please don't start a new thread for every small aspect of using it - as such I'm locking this copy - suggest you continue in that other one - rename the thread if you like (edit subject in first post).

2) Apart from the fact that FatFs happens to be ported for avr-gcc nothing about any of this is GCC specific so this is the wrong forum anyway.

Topic locked