I tried to connect the two memory card devices by connecting it on ssp port of lpc2148, i have access to memory cards when i enabling them one by one but i can't access memory card device 1 when i'm enabling the both devices on file configuration.c I connected both card's MOSI,MISO,SCLK on same ssp port of lpc2148,i'm using GPIO port 0.20 for ss of one memory card and GPIO port 0.07 of another memory card
I used example program for SD_file in MCB2140 ,i modified spi driver with ss pin as gpio port 0.07 for second device,for first device i'm using inbuilt spi driver
NOTE: I can access both device separately on same bus,i can't able to access them at a time
PLS give some idea
If you have two drivers - wouldn't that imply that both memory cards should be accessible concurrently? How would the file system know that it must wait for the end of a transfer to one card before it is possible to try a transfer to the other card?
Have you added any code to check that the two drivers aren't activated at the same time?
I'm initialized cards using finit(NUll),after that i don't got any return value from that function,when i using finit("MC0"),i got return value of 0 (initialization success) when i using finit("MC1"),the function execution goes as infinite loop without any return value.
NOTE: for all this i enabled both card devices in file configuration .c
...the function execution goes as infinite loop without any return value. In which infinite loop does it get stuck-up in? Have you checked if any fault is generated or not? (Bus Fault, memory management fault, hard fault...) Debug and check.
I didn't see you supply any answer to my question: "Have you added any code to check that the two drivers aren't activated at the same time?"
It doesn't seem like you are trying to solve your problem by trying to figure out what goes wrong.
My code get stucked for initializing two memory cards in a row,my code get stucked on finit function when i configure it for two memory cards,i checked that in finit(NULL) function it is able to only activate default drive ,i had no idea about finit function ,i hadn't added any codes to check. both memory cards are working perfectly in the same bus activated separately in file configuration, i think that hardware part has no problem.is there any limitation in memory card size? i'm using 2gb memory cards,pls guide me Thanking you sry for delay to answering ur questions
I have problem on initializing both cards at a time,i got stucked in finit(NULL) function which goes infinite loop when i using 2gb transcend memory cards connected in a same SSP port i only modified slave select for two cards and defined spi1 drv and spi0 drv drivers ,i got better result in using SD_FIle example from keil for mcb2140 these drivers when activating two cards seperately ,in two cards configuration the code is stucked on initializing memory card which is not a default one,i tested activating two cards seperately by using finit("MC0")and finit("MC1")
But what have you done to try to DEBUG your problems?
Have you checked if your drivers gets called?
Does one gets called while the other still have the SPI port busy?
How do you even know that your code is correct?
We don't care much if the program gets stuck in an infinite loop. Why? Because it is't our program. So - what are YOU doing about this issue? Besides spending time on the web telling people that your code gets stuck in an infinite loop, that is...
Have you checked where that loop is? Inside what function? Or in an exception handler? Or waiting for a hardware condition that can't happen because your code doesn't do what it should?
I have no idea how to DEBUG code because it working perfectly when I using single memory card and checked another card also for same condition ,if I enabled two drives only one card get initialized but another card doesn't get initialized by flashfs ,I have no idea to debug this because I don't know internal routines of flashfs function finit. Pls instruct me how to debug on it,I think that there is memory management problem in flashfs for initializing two memory card,may using file cache will remove this problem I need ur guidance for this issue Thanking you
> if I enabled two drives
How did you enable two drives? I believe this the supposed way to add MC1.
1) Enable MC1 in File_Config.c
C:\Keil\ARM\Boards\Keil\MCB2140\RL\FlashFS\SD_File\File_Config.c // </e> // <e>Memory Card Drive 1 // ====================== // Enable Memory Card Drive [M1:] #define MC1_EN 0 // <---- 1
Optionally, you may attach a cache (MC1_CASZ) to this drive, like MC0 In this case, the cache address (MC1_CADR) should be placed, so that it doesn't overlap MC0's.
2) Add another SPI driver object (spi1_drv) for MC1 Copy and modiy the SPI driver file (SPI_LPC214x.c) for MC1
C:\Keil\ARM\Boards\Keil\MCB2140\RL\FlashFS\SD_File\SPI_LPC214x_MC1.c (copied SPI_LPC214x.c) #define __DRV_ID spi0_drv // <---- spi1_drv
In your case, SetSS() is customized, too, to select target SD card, both in the original and copied. As most of the routines on the copied file is common to the original, You may combine them into single file.
Tsuneo
He's still likely to have to do something in his hardware abstraction code to mediate/arbitrate access between the two mutually exclusive devices. This is not a responsibility of the file system, but rather the driver for the board/card scheme.
The driver side would appear to function at the individual level, and that's great, but code is still going to need to be written to manage the two together. This part is missing, poking at the existing code isn't going to address that.
So it's stuck in a loop, ok that's great, but why? If you don't sufficiently grasp the low level driver code, and the interplay with the higher level code, then you'll need to instrument the interface points, and become familiar with what's happening, when and why.
This isn't Keil's responsibility, it is the responsibility of the implementer, the one tasked with making the board support package or board drivers. If the task exceeds your skillset consider out-sourcing the task.
> but code is still going to need to be written to manage the two together.
I believe the target drive managemnet is already there, without any additional code by user. In the SPI connection of SD card, - CS is asserted to start an operation (command - response - data). - CS must be kept active while an operation is going on. - At the end of operation, CS is deserted.
CS (SS) is also applied to activate one of SD cards, which share single SPI bus. Therefore, operations occur exclusively for each SD card on the bus.
"CS (SS) is also applied to activate one of SD cards, which share single SPI bus"
But is that actually designed & able to manage two separate CS (SS) lines to select between one of two SD cards sharing the same SPI bus...?
I'm using seperate cs(ss)for each sd card
I think that cs assertion and deassertion will happen when initializing a card with fat initialization if it is defined in low level spi driver needed for Flash fs
You think?
And you think debugging shouldn't be used to verify that one driver is 100% done with the interface before the other driver gets jobs to do?
>Andrew Neil: But is that actually designed & able to manage two separate CS (SS) lines to select between one of two SD cards sharing the same SPI bus…?
It's already added, as described on my above post. "2) Add another SPI driver object (spi1_drv) for MC1 In your case, SetSS() is customized, too, to select target SD card, both in the original and copied."
Ravi, Maybe, spurious signaling on the SPI bus makes the second SD card confused.
1) Pull-up resistors at SPI pins and each CS (SS) pin The I/O ports of LPC2148 are set to input (floating) after reset, including power up. To avoid spurious signaling on SPI bus, these pull-ups are required.
2) Init() / UnInit() on the SPI driver The original Init()/UnInit() routines in SPI_LPC214x.c touch to SPI and SS ports setting. The ports should be initialized once, at the global start-up initialization. And they should be kept untouched while the MCU is running.
Init() / UnInit() change just SPI registers.
C:\Keil\ARM\Boards\Keil\MCB2140\RL\FlashFS\SD_File\SPI_LPC214x.c static BOOL Init (void) { /* Initialize and enable the SSP Interface module. */ /* <------- move these lines into the global start up initialization // SSEL is GPIO, output set to high. IODIR0 |= 1<<20; IOSET0 = 1<<20; // SCK1, MISO1, MOSI1 are SSP pins. PINSEL1 = (PINSEL1 & ~0x000003FC) | 0x000000A8; */ // reset SPI SSPCR1 = 0x0000; SSPCR0 = 0x0000; SSPCPSR = 0x00; /* Enable SPI in Master Mode, CPOL=0, CPHA=0. */ SSPCR0 = 0x0007; SSPCR1 = 0x0002; SSPCPSR = 0xFE; return (__TRUE); } /*--------------------------- UnInit ----------------------------------------*/ static BOOL UnInit (void) { /* Return SSP interface to default state. */ /* <---- delete these lines IODIR0 &= ~(1<<20); PINSEL1 &= ~0x000003FC; */ SSPCR1 = 0x0000; SSPCR0 = 0x0000; SSPCPSR = 0x00; return (__TRUE); }
3) finit() finit(NULL), in init_card() on the demo, initializes both of SD cards. To ensure separate initialization per the cards, this call is replaced with finit("M0:") and finit("M1:")
C:\Keil\ARM\Boards\Keil\MCB2140\RL\FlashFS\SD_File\SD_File.c static void init_card (void) { U32 retv; while ((retv = finit (NULL)) != 0) { // Wait until the Card is ready