LPCUSBlib + FatFS + USB Write Error while powering down periodically

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPCUSBlib + FatFS + USB Write Error while powering down periodically

960 Views
tojo_thomas
Contributor II

Hi,

I have been using LPCUSBlib and FatFS in my project to support USB as a host. In my project, I store data to the USB device periodically. It was working smooth until I introduce a power save option.

 I tried to power down the USB when it is not in use. It saved me a lot of power conception. I was happy, and it looked working but some USB devices doesn’t like this power down. I found data loss on these USB’s. I loss the data which I write to the last file.

 

Starting Up

Create folder1->file1 and write some data

Create folder2->file2 and write some data

Create folder3->file3 and write some data

 

Power Down the USB

... 

Power Up the USB

Append some data to folder1->file1

Append some data to folder2->file2

Append some data to folder3->file3

 

Power Down the USB

 

When I check the files, data in the file3 found missing.

 

Any help is appreciated.

Thanks in advance.

Labels (3)
0 Kudos
4 Replies

756 Views
FelipeGarcia
NXP Employee
NXP Employee

Hi,

 

Could you please describe how are you powering down the USB module?

 

Also, which software example are you working on?

 

Could you please make sure you have finished writing data in the file 3 before you power down the USB module? I believe the transmission was on the run and it didn’t finished correctly.

 

Best regards,

Felipe

0 Kudos

756 Views
tojo_thomas
Contributor II

Hi Felipe,

Thanks for the reply.

I power down the USB by disabling the 12th bit(Port power control) of the PORTSC1_H register(Port 1 status/control (host mode)).

I have used the "lpcusblib" for the USB functions and for the file system I use the FatFS (http://elm-chan.org).

After the last file transfer, I wait another 1 minute before turning off the USB power. I assume, that might be sufficient to complete the file data write.

It is not happening to every USB device. Is it related to any cache memory? Is there any function to flush the USB cache?

Thanks in advance.

Tojo

0 Kudos

756 Views
FelipeGarcia
NXP Employee
NXP Employee

Hi Tojo,

 

The USB power consumption can be controlled by disabling the USB clocks and disabling

the High-speed PHY.

 

You can send your USB module to a low power suspended state. You can enter this state by setting PORTSC1.PHCD bit.

 

I recommend you to check chapter 23.12 of the User Manual for further information regarding USB suspended state.

 

I hope this information helps you.

 

Best regards,

Felipe

0 Kudos

756 Views
tojo_thomas
Contributor II

Hi Felipe,

Thank you so much.

I will go through the manual.

Thanks again for the information. 

Kind Regards,

Tojo

0 Kudos