Nuvoton ARM Cortex M0 M4

 Forgot password?
 Register
Search
Hot search: MINI51 NUC M051 M4 NANO
Author: raisen88

need help on the SDcard module [Copy this link to quote]

Rank: 2

Post time: 2015-04-12 14:05:47
|Show all posts
Edited by raisen88 at 2015-04-12 14:37

Dear prima,

I've found some strange portion during the code executionin the debug mode. I really hope you can look into it seriously or direct my questions to someone familiar with the board/coding.

In the function "disk_initialize()" in "diskio.c":

DSTATUS disk_initialize (
        BYTE drv                /* Physical drive number */
)
{
        DSTATUS sta;
        GPIOD->PMD.PMD12=1;  //GPIOD port[12] as output mode
        GPIOD->DOUT&=0xEFFF;


        while((GPIOD->PIN&0x2000)!=0);
        RoughDelay(100000);
        if(DrvSDCARD_Open() == E_SUCCESS)
        {        
        sta =         RES_OK;
                printf("SDCard Open success\n");
        }
        else
        {
        sta = STA_NOINIT;
                printf("SDCard Open failed\n");
        }
        return sta;


}



1. Before any code execution, the GPIOD->DOUT is default as 0xFFFF FFFF, but in the NUC140 technical reference (as attached) it is written reset status as 0x0000 FFFF (DOUT[31:16]=reserved bits)??


2. After setting GPIOD->PMD.PMD12=1, the GPIOD->DOUT AUTOMATICALLY changed to 0xFDFF FFFF. Even after executing the next line, GPIOD->DOUT&=0xEFFF, GPIOD->DOUT still remain as 0xFDFF FFFF. Why is this????


3. After a few trials, I also found that the GPIOD->DOUT change accordingly to GPIOD->PMD.PMDnwith a similar pattern as follows:
     PMD0=1 ----> GPIOD->DOUT = 0xFFFF FFFD = 1111 1111 1111 1111 1111 1111 1111 1101
     PMD1=1 ----> GPIOD->DOUT = 0xFFFF FFF7 = 1111 1111 1111 1111 1111 1111 1111 0111
     PMD2=1 ----> GPIOD->DOUT = 0xFFFF FFDF = 1111 1111 1111 1111 1111 1111 1101 1111
     PMD3=1 ----> GPIOD->DOUT = 0xFFFF FF7F = 1111 1111 1111 1111 1111 1111 0111 1111
     ......
     ......
so, PMD12=1 ----> GPIOD->DOUT = 0xFDFF FFFF = 1111 1101 1111 1111 1111 1111 1111 1111


It unsetting the (n*2)th bit when GPIOD->PMD.PMDn is set to 1. Are they supposed to change at the same time. If i understood correctly, the GPIOD->DOUT should be set/unset manually (here using 0xEFFF to set the 12th bit to 0).


What is the use of GPIOD[12] anyway? From the schematic, I know that it is use to control the VCC3.3V (the gate of PFET QS1) to the SD card interface. It should be low all the time in order for the SD card to be supplied with 3.3V, am I right?


Please advice.


Thanks.

Best regards,
Wong
Attachment: You have to Login to download or view attachment(s). No Account?

Use magic Report

Rank: 8Rank: 8

Post time: 2015-04-13 13:54:13
|Show all posts
Edited by prima.sp at 2015-04-13 13:58

Dear Wong,

1.         For mytest in debug mode, GPIOD_DOUT is default as 0x0000FFFF, the same as TRMrefered.


2.         Aftersetting GPIOD_PMD.PMD12=1, GPIOD_DOUT is still 0x0000FFFF.


3.         These tworegisters shouldn’t affect each other. PMD is used to control GPIO mode, butDOUT is output value for GPIO when it is set as output, open-drain andquasi-mode.


4.         Yes,PD.12 is used to control the QS1. When PD.12 is output low, QS1 will trun onand it will supply the power for SD Card.

5.         I suggestyou to check whether sfr file is suit for ot not first.



Thanks and best regards,

林昌宏/ Henry



Attachment: You have to Login to download or view attachment(s). No Account?

Use magic Report

Rank: 8Rank: 8

Post time: 2015-04-13 14:02:11
|Show all posts
Dear Henry,

Thanks for your reply.

May I know which sample code / revision are you using? Which Keil driver revision? And which board are you using?

I'm using Keil driver 6386 and the board Nu-LB-NUC140 V2.0. The sample code that I use is the "Smpl_SDcard_ADC7" in the BSP "NUC140BSP_EDU_20140810" (as provided by prima in the forum).

The sfr I'm not sure of the configuration but what I have now is as attached file.

Is there anything wrong? I can't find the target device as you have-> NUC140VE3CN. The Keil uVision I'm currently using is V4.50.

Can you please advise?

Thanks in advance.


Best regards,
Wong
Attachment: You have to Login to download or view attachment(s). No Account?

Use magic Report

Rank: 8Rank: 8

Post time: 2015-04-13 14:07:44
|Show all posts

Dear Wong,


I think you have to change devicefirst.


Sfr will auto-change to newest sfr.


But make sure the “Debug” and“Utilities” is selected to Nu-Link



Thanks and best regards,

林昌宏/Henry

Attachment: You have to Login to download or view attachment(s). No Account?

Use magic Report

You have to log in before you can reply Login | Register

Archiver| Nuvoton ARM Cortex M0 M4

2017-03-26 03:42 GMT+8 , Processed in 0.055095 sec., 8 queries

Powered by Discuz! X2, Release 20111010 © 2001-2011 Comsenz Inc.

English version, Rev. 146, © 2009-2011 Valery Votintsev

To Top