FATFS driver conflict on K66F

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

FATFS driver conflict on K66F

Jump to solution
1,987 Views
jeffsylvester
Contributor III

Any app notes, or instructions on the FATFS driver for SDCards on MCUExpresso?   I can run the SDCard with FAT File System demo/example code just fine, and I can run the FTM Quadrature Encoder Example code just fine, but when I combine these into one project, the SDCard fails in function, SDMMCHOST_Transferfunction() in SD_SendScr() inside of the function SDCardInit().     I have been trying to work the project backwards,  and it does not appear to be the device configuration,  because I use the same configuration file frdmK66_demoboard.mex for all 3 projects. (the board.c/h, clock_config.c/h, peripherals.c/h and pin_mux.c/h are the same for all 3 projects)  I can run each example code successfully by itself, but when merged, something is blocking or interfering with sdcard.  I looked farther into the code and it is using DMA access, Interrupts, timers, and probably several other things I dont know about, are there any notes on this?    

I am working with McuExpresso 11.0 and SDK 2.6 on freedom K66F board.  Is there any document anywhere that tells me what resources the SDcard driver for FAT file system is using.  

I am systematically disabling parts of the code to see if I am getting timer contention, interrupt contention, Dma contention, etc..  with no luck.  

0 Kudos
1 Solution
1,764 Views
jeffsylvester
Contributor III

thanks for the suggestions,  I found the solution, the errors I was seeing were only symptoms of the actual problem.  there was one line of code missing and in actuality it makes no sense to me why it matters, but I wasted enough time on this already.  so if it now runs I guess I don't care anymore.  since there is no documentation what so ever and it appears that this driver was taken from some other examples on other processors, but the problem was  SYSMPU_Enable(SYSMPU, false);   which disables the Memory Protection Unit.   This was coppied directly from the manual.  At reset, the MPU is enabled with a single region descriptor (RGD0) that maps the entire
4 GB address space with read, write and execute permissions given to the core, debugger
and the DMA bus masters.

View solution in original post

0 Kudos
7 Replies
1,764 Views
Alexis_A
NXP TechSupport
NXP TechSupport

Dear jeff_sylvester‌,

Can you check what if the error is in the SDHC_TransferNonBlocking function, or is a timeout from the function SDMMCEVENT_Wait in the SDMMCHOST_TransferFunction?

Also, only to check if there's any colision between the FTM and the SD, could you enable first the SD before enable the FTM?

Best Regards,

Alexis Andalon

0 Kudos
1,764 Views
jeffsylvester
Contributor III

yes thank you for looking at this,  the code fails because (!g_sdhcTransferSuccessFlag) which is related to the interrupt handler SDMMCHOST_TransferCompleteCallback.   so either the interrupt is being interfered with, or it is not being registered?   

this should be registered by demo code function sdcardWaitCardInsert() -> SD_Init() -> SDMMCHOST_Init() -> SDMMCHOST_TransferCompleteCallback

looks like it actually get to the callback but has status error.  

continuing on in the code, I can see SDHC_IRQHandler being accessed. calling SDHC_DriverIRQHandler(); and I see some access to SDHC_TransferHandleIRQ.  so at least some interrupts are working,   so I turned on the SDMMC_LOG and it tells me this Error: send ACMD51 failed with host error 1, response 0"

Fatfs_Driver_Failure2.PNG

this fails because (error = 1) in the above transfer.  error = card->host.transfer(card->host.base, %content);

so inside of SDMMCHOST_TransferFunction()   i get (!g_sdhcTransferSuccessFlag) failure.

Fatfs_Driver_Failure3.PNG

0 Kudos
1,764 Views
Alexis_A
NXP TechSupport
NXP TechSupport

Dear Jeff,

Could you try stopping the FTM counter from the quad encoder while this transmission is being done? I'm thinking that maybe one of the FTM interrupt is corrupting the writing to the SD.

Also, are you using the same SD that works with the project standalone?

Best Regards,
Alexis Andalon

0 Kudos
1,764 Views
jeffsylvester
Contributor III

I will try and see what I find, however, our application is FTM always highest priority, and data logging always secondary, currently code is power up, do regular init functions, do sdcard demo code and try to create a file,   << fails >>   then do infinite sensor loop doing FTM and send out FTM data at 100 Hz.   ( then eventually add logging of FTM data to SDCard )    so basically i run sample / demo code from sdcard, then run demo code from FTM    so much of the program is just a merger of the two sample /  demo projects, both demos run stand alone, but when merged, has some issue affecting sdcard init,  our application uses a lot of peripherals.  I2C port 0,1  Uart 0,1,2,3,4,  FTM1,   << CAN0 future >> , SDcard.  RGB Led, 

0 Kudos
1,764 Views
Alexis_A
NXP TechSupport
NXP TechSupport

Hi Silverster,

You could try sending short buffers after each transmission of FTM to be sure there will be any interruption in the middle. Also each of the other transmissions should respect the same logic. Maybe an RTOS could help you managing all the interruptions.

Best Regards,

Alexis Andalon

0 Kudos
1,765 Views
jeffsylvester
Contributor III

thanks for the suggestions,  I found the solution, the errors I was seeing were only symptoms of the actual problem.  there was one line of code missing and in actuality it makes no sense to me why it matters, but I wasted enough time on this already.  so if it now runs I guess I don't care anymore.  since there is no documentation what so ever and it appears that this driver was taken from some other examples on other processors, but the problem was  SYSMPU_Enable(SYSMPU, false);   which disables the Memory Protection Unit.   This was coppied directly from the manual.  At reset, the MPU is enabled with a single region descriptor (RGD0) that maps the entire
4 GB address space with read, write and execute permissions given to the core, debugger
and the DMA bus masters.

0 Kudos
1,658 Views
yogesh_modi
Contributor II

Hello,

I'm facing the same issue, can you please explain me how did you resolved it. I also tried to trace the issue but didn't found any visible difference in my code and the example, So please help @jeffsylvester 

0 Kudos