Mmc_Init() and SPI port

General discussion on mikroBasic PRO for dsPIC30/33 and PIC24.
Post Reply
Author
Message
arco
Posts: 312
Joined: 15 Apr 2008 13:54
Location: The Netherlands

Mmc_Init() and SPI port

#1 Post by arco » 15 Mar 2017 21:51

I'm using a PIC24FJ256GA108 with 3 SPI buses, on one of them an SD card. I'm not quite clear how I can 'attach' the MMC functions to a specific SPI bus.
Now it seems to be dependant on the initialization sequence of the ports. Last initialized SPI bus gets the MMC functions and SD card.
That's not workable. The SPI buses often get re-initialized, and then the SD card suddenly moves to another bus. (on which it's not connected)
How do I make a fixed connection between SD card/MMC functions and an SPI bus?
For now it seems fuzzy logic. The SD card is randomly connected to one f the three SPI buses. Not very useful at all...
Regards,

Peter.

User avatar
dusan.poluga
mikroElektronika team
Posts: 780
Joined: 02 Feb 2017 14:21

Re: Mmc_Init() and SPI port

#2 Post by dusan.poluga » 16 Mar 2017 17:00

Hi,

MMC library uses the SPI interface that is last initialized.

Regards,
Dusan Poluga.

arco
Posts: 312
Joined: 15 Apr 2008 13:54
Location: The Netherlands

Re: Mmc_Init() and SPI port

#3 Post by arco » 16 Mar 2017 18:54

After using MMC_Init(), will it keep using that SPI port? It must be possible to use a fixed port for MMC.
This 'Russian roulette' isn't very useful... :)
Regards,

Peter.

User avatar
dusan.poluga
mikroElektronika team
Posts: 780
Joined: 02 Feb 2017 14:21

Re: Mmc_Init() and SPI port

#4 Post by dusan.poluga » 17 Mar 2017 17:49

Hi,

When you call for example SPI1_Init(); and then after that MMC_Init(); MMC function should grab pointers from that spi.
After that it should remain on that spi interface. You can then initialize rest of the spi interfaces.
If you do something like this:

Code: Select all

SPI1_Init();
MMC_Init();
SPI2_Init();
SPI3_Init();
MMC_Init();
The MMC_Init(); will grab the last spi interface that was initialized. So instead of having it on SPI1 you will have it initialized for SPI3.

Regards,
Dusan Poluga.

Post Reply

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