Help with USB Mass Storage Library

General discussion on mikroPascal PRO for dsPIC30/33 and PIC24.
Post Reply
Author
Message
karl567
Posts: 64
Joined: 19 Apr 2012 17:25
Location: Konstanz

Help with USB Mass Storage Library

#1 Post by karl567 » 25 Jun 2016 10:44

In my application I am using the MicroSD-card as a Mass Storage Device.
The procedure USBDev_MSCMain is called periodically in the main-routine. It works fine.

But I also need to read images from the same MicroSD-card for internal use.
For this I use the function TFT_Ext_Image from TFT-Library.
Sometimes after getting an image USBDev_MSCMain hangs.

Is it not possible that the 2 librarys are working parallel?
Is there something I must consider for both working properly?

Compiler I am using:
MikroPascal V6.2.1
dsPIC33EP512MU810

karl567
Posts: 64
Joined: 19 Apr 2012 17:25
Location: Konstanz

Re: Help with USB Mass Storage Library

#2 Post by karl567 » 25 Jun 2016 16:31

I think I found the solution:
After opening the file with Mmc_Fat_Assign, it must be closed with Mmc_Fat_Init.
Now USBDev_MSCMain runs without hanging.

Is this the normal way to solve this problem?
Has someone a similar problem?

Code: Select all

procedure picture();
begin
  if Mmc_Fat_Assign(file,1)
  then  begin
    TFT_Ext_Image(posx,posy,pt^.picture,1);
    Mmc_Fat_Init();
  end;
end;

while (true) do        // Main
begin
  if USBState=_USB_DEV_STATE_CONFIGURED
  then USBDev_MSCMain();
  ....
end;

User avatar
biljana.nedeljkovic
mikroElektronika team
Posts: 1043
Joined: 30 Jun 2015 15:15

Re: Help with USB Mass Storage Library

#3 Post by biljana.nedeljkovic » 28 Jun 2016 15:19

Hello,

Please check our MMC Library and the explanation for the functions, MMC_Fat_Init() is used to initialize the MMC/SD card, so if you use the library, you have to initialize the card.

In the Help file, there are various examples you can check out.

It would be great if you want to attach the project, since this type of problem is not familiar and I could run some tests in order to help you.

Kind regards,
Biljana

karl567
Posts: 64
Joined: 19 Apr 2012 17:25
Location: Konstanz

Re: Help with USB Mass Storage Library

#4 Post by karl567 » 29 Jun 2016 05:32

Hi,

thank you Biljana for your answer.
Surelly MMC is initialized. And all works, only the above mentioned problem.

Among others I am using this librarys:
Mmc-Librarys, TFT-Librarys, USB_Device_dsPIC-Library

I will try to extract some parts of the software concerning the Mmc-problem. But I need time (I think its a common problem).
After over 3 years of development my project has grown very big.

Other problems and strange behaviors:

(USBDevice is a boolean variable):
1.) USBDevice:=(USBState=_USB_DEV_STATE_CONFIGURED)
2.) if USBState=_USB_DEV_STATE_CONFIGURED then USBDevice:=1 else USBDevice:=0;
Normally both must give the same result. But I spend one night with it. The first one works only by mood? Or am I blind?

The optimization level!
After 3 years of development I have problems understanding it. I miss an abstract for understanding what they are doing.
If I choose the recommended level, the compiler optimizes too much and swallows line of code I am needing.
If I choose Level Zero and no SSA then the VisualTFT-code don't works.
My solution: Rebuild all sources with Level 4 (VisualTFT is happy) and then build my own units with Level 1.
Sadly I have no other solution.

OK. Enough for today. I get along with my project.

Best regards,
Karl

User avatar
biljana.nedeljkovic
mikroElektronika team
Posts: 1043
Joined: 30 Jun 2015 15:15

Re: Help with USB Mass Storage Library

#5 Post by biljana.nedeljkovic » 29 Jun 2016 10:31

Hi Karl,

Unfortunately, we have developed the compiler and libraries with the Optimization Level 4, and yes, as a workaround, build everything with this level 4 first, and change the level of optimization for particular units.

Please attach small part of the project that can help us determine what can be the issue with the boolean problem that you reported.

Looking forward to your answer.

Kind regards,
Biljana

Post Reply

Return to “mikroPascal PRO for dsPIC30/33 and PIC24 General”