I need help: Fatfs SD... using SPP0

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

I need help: Fatfs SD... using SPP0

1,888 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by MAUROFIUNER on Fri Oct 25 09:03:19 MST 2013
Hi, Im trying use Chan's FatFs Sd Library..but i'cant!   mmc.c uses SSP1..What considerations should I have for use SSP0?

I have
(is'nt possible to change)

* P0.16 - SSEL- used as GPIO
* P0.15 - SCK;
* P0.17 - MISO
* P0.18 - MOSI

uC: lpc1769

tanks a lot!
标签 (1)
0 项奖励
回复
5 回复数

1,793 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by MAUROFIUNER on Mon Oct 28 09:06:14 MST 2013
Hi,
Something strange happens, when the sd card is out debugging works fine, but when I plug the card this error occurs (look at the attached image)

tanks!
0 项奖励
回复

1,793 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Rob65 on Sun Oct 27 10:43:12 MST 2013
Seems like you have a simple debugging issue.
Only startup code runs before main so none of your stuff is being touched before your code runs.

Standard debug issue: standard solution? Try one of the easier examples and see if you can debug those.
0 项奖励
回复

1,793 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by MAUROFIUNER on Sat Oct 26 13:17:13 MST 2013
Hi tnks for help me, (I Attach the mmc.c,,,)

First I set the ssp0 interface..
static void init_ssp(void)
{
SSP_CFG_Type SSP_ConfigStruct;
PINSEL_CFG_Type PinCfg;

/*
* Initialize SPI pin connect fn=2 ssp0
* P0.16 - SSEL- used as GPIO
* P0.15 - SCK;
* P0.17 - MISO
* P0.18 - MOSI
*/
PinCfg.Funcnum   = 0; //General purpose digital input/output pin
PinCfg.OpenDrain = 0;//Pin is in the normal (not open drain) mode
PinCfg.Pinmode   = 2; //pin has neither pull-up nor pull-down... beacause I've external 10k pull up resistors...
PinCfg.Portnum   = 0;
PinCfg.Pinnum = 16;
PINSEL_ConfigPin(&PinCfg);

PinCfg.Funcnum   = 2; //function 2 ssp0
PinCfg.OpenDrain = 0;//Pin is in the normal (not open drain) mode
PinCfg.Pinmode   = 2; //pin has neither pull-up nor pull-down
PinCfg.Portnum   = 0;
PinCfg.Pinnum = 15;
PINSEL_ConfigPin(&PinCfg);
PinCfg.Pinnum = 17;
PINSEL_ConfigPin(&PinCfg);
PinCfg.Pinnum = 18;
PINSEL_ConfigPin(&PinCfg);

SSP_ConfigStructInit(&SSP_ConfigStruct);

// Initialize SSP peripheral with parameter given in structure above
SSP_Init(LPC_SSP0, &SSP_ConfigStruct);

// Enable SSP peripheral
SSP_Cmd(LPC_SSP0, ENABLE);
}

with respect to the timing...........

void SysTick_Handler(void) {
    disk_timerproc();
}

and
...     SysTick_Config(SystemCoreClock / 100);


then I change the mmc.c references from SSP1 into SSP0..

1- #define CS_LOW()    GPIO_ClearValue ( 0, 1<<16 )   //P0.16 CS
    #define CS_HIGH()   GPIO_SetValue      (0, 1<<16)     //P0.16 Cs

2-     SSPSend//SSPReceive(...)
                                                    SSP_ReadWrite(LPC_SSP0, &xferConfig, SSP_TRANSFER_POLLING);

3-    disk_initialize (...)
                                     GPIO_SetDir(0, 1<<16, 1);   /* CS... P0.16 output*/
                                 //  GPIO_SetDir(2, 1<<11, 0);  /* Card Detect */.................     What should I do with this?  I have not  that connection

4- disk_timerproc(...)
                                     pv = ((GPIO_ReadValue(2) & (1<<11)) != 0); // ................... newly this


................
when start debugging the PC goin to any place... not even reach the breakpoint on the first instruction of the main()...

Thanks a lot!
Forgive my English

0 项奖励
回复

1,793 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Rob65 on Sat Oct 26 06:00:18 MST 2013
Indeed,

just change all references from SSP1 into SSP0, do the correct pinsel stuff and don't forget to change any settings that involve clocking and enabling the SSP0 block.

With the LPC17xx user manual this is a piece of cake - just check the SSP0 chapter, there is a list of items with all the settings.

Or just see AN10916 "FAT library EFSL and FatFs port on NXP LPC1700" on the nxp.com website. This application note contains a complete FatFS implementation on SSP0  :)

Rob
0 项奖励
回复

1,793 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Martin84 on Fri Oct 25 14:16:09 MST 2013
Hi,

hm. what's the problem? You have to config the pin functions (see Pin Connect Block) for P0.15 - P0.18 for SSP0 and then replace only the SSP1 parts of your code with SSP0.

I'm also interested in working with the FATFs, so you can post your questions and problems, so I can also learn from the answers :-)

Regards,

Martin
0 项奖励
回复