AnsweredAssumed Answered

STM32F xxx Strange USB File Write Error - HS Mode Only

Question asked by ryan.louis on Feb 10, 2014
Latest reply on Feb 11, 2014 by ryan.louis
Hi,
I am getting a strange file write error when using HS USB lib and FATfs. this error does not occur in FS mode.

When I write 2 bytes to a file and then 1024 bytes, some (2)  of the 1024 bytes are repeated at 0x200. See picture below.

If I don't write the 2 bytes first then all appears to be OK.

I am working on a STM32F407 and have a USB3200 PHY. ( However the same problem also occurs on the STM3220G-EVAL. board )

I run the following code 

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "ff.h"


FIL fileptr;


unsigned char line[1024];


int filetest(void)
{
uint16_t      un16BytesWritten;
uint16_t     un16Counter;
uint8_t          un8ByteValue=0;
uint16_t     un16Status;


     // File the line with 0x00 - 0xFF
     for(un16Counter=0;un16Counter<1024;un16Counter++){
          line[un16Counter]=un8ByteValue++;
          }


     // Open File and Write Data
     if(f_open(&fileptr, "0:BIT_HS2.bmp",FA_CREATE_ALWAYS | FA_WRITE) == FR_OK)
         {
        un16Status=f_write(&fileptr,&line,2,&un16BytesWritten);


             un16Status=f_write(&fileptr,&line, 1024 , &un16BytesWritten);


         un16Status=f_close(&fileptr);


         return(0);
          }
     else
           return(1);
}

Bytes%20Repeated.png

In FS mode these bytes are not repeated.

Anybody have any ideas?

thanks for looking,
Louis

Outcomes