PIC32MZ SPI - MMC - Problem

General discussion on mikroC PRO for PIC32.
Post Reply
Author
Message
Primology
Posts: 23
Joined: 23 Apr 2015 01:00
Location: Скопје, Македонија

PIC32MZ SPI - MMC - Problem

#1 Post by Primology » 19 Aug 2016 14:03

Dear Friends,

I am trying to play a sound.mp3 from my sd card ,but i receive a error 255 (SD card not found)
The micro sd is SDHC ,cut down to 4GB and FAT16 formatted.

Here is what i have written so far. I have been trying and reading the DataSheet ,so telling me to do that is not quite helping because i have spent a lot of time reading it and have trouble understanding it.

Unlike the P32MX this chip (P32MZ2048ECH124) uses ANSEL and not AD1PCFG. I also tried modifying the Example for P32MX to work on my P32MZ ,but i haven't done any progress ,i receive the same error.

I also have the FAT32 library (same error).
My guess is that i am not initializing something properly (either the SPI or ADC pins).
If anyone can help me understand my lack of skills i will be very grateful due to the fact that there is no one i know that knows microprocessors to help me better understand them.

My gear:
mikroC PRO for PIC32
EasyPIC Fusion v7
PIC32MZ2048ECH124 @ 200MHz
Implemented VS1053b
Implemented MicroSD slot
SDHC 8GB card ,reduced to 4GB FAT16 (leaving 4GB of free space un-allocated)

ANY info you have on anything regarding MCU's will be helpful due to the fact that i apparently lack the understanding of things.

Code: Select all

// TFT module connections
char TFT_DataPort at LATE;
sbit TFT_RST at LATD7_bit;
sbit TFT_BLED at LATD2_bit;
sbit TFT_RS at LATD9_bit;
sbit TFT_CS at LATD10_bit;
sbit TFT_RD at LATD5_bit;
sbit TFT_WR at LATD4_bit;
char TFT_DataPort_Direction at TRISE;
sbit TFT_RST_Direction at TRISD7_bit;
sbit TFT_BLED_Direction at TRISD2_bit;
sbit TFT_RS_Direction at TRISD9_bit;
sbit TFT_CS_Direction at TRISD10_bit;
sbit TFT_RD_Direction at TRISD5_bit;
sbit TFT_WR_Direction at TRISD4_bit;
// End TFT module connections

//MMC connections
sbit Mmc_Chip_Select at RD12_bit;
sbit Mmc_Chip_Select_Direction at TRISD12_bit;

void main(){
  AD1CON1 = 0x00;
  AD1CON2 = 0x00;
  AD1CON3 = 0x00;
  CM1CON = 0x00;
  CM2CON = 0x00;
  ANSELD = 0;

  TFT_Init_ILI9341_8bit(320, 240);
  TFT_Fill_Screen(CL_PURPLE);
  TFT_Set_Font(TFT_defaultFont, CL_BLACK, FO_HORIZONTAL);
  TFT_Write_Text("FAT32", 0, 0);
  SPI1_Init_Advanced(_SPI_MASTER, _SPI_8_BIT, 64, _SPI_SS_DISABLE, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_HIGH, _SPI_ACTIVE_2_IDLE);
  
  if (Mmc_Fat_Init() == 0){
   TFT_Write_Text("FAT32 Initialized", 0, 50);
   Delay_ms(5000);
  }
  else if(Mmc_Fat_Init() == 1){
   TFT_Write_Text("Error: 1", 0, 50);
   Delay_ms(5000);
  }
  else if(Mmc_Fat_Init() == 255){
   TFT_Write_Text("Error: 255", 0, 50);
   Delay_ms(5000);
  }
}

User avatar
uros.cvetinovic
mikroElektronika team
Posts: 803
Joined: 14 Dec 2015 09:24

Re: PIC32MZ SPI - MMC - Problem

#2 Post by uros.cvetinovic » 22 Aug 2016 16:39

Hi,

I believe I have answered you on your ticket on this matter.

We can continue our correspondence there.

Best regards,

Uros

ahmed.hasib
Posts: 71
Joined: 11 Jul 2015 17:59

Re: PIC32MZ SPI - MMC - Problem

#3 Post by ahmed.hasib » 16 Oct 2018 10:42

Hi,
i have the same problem but i use mikrobasic for pic32
could you help me!

ahmed.hasib
Posts: 71
Joined: 11 Jul 2015 17:59

Re: PIC32MZ SPI - MMC - Problem

#4 Post by ahmed.hasib » 16 Oct 2018 11:15

uros.cvetinovic wrote:Hi,

I believe I have answered you on your ticket on this matter.

We can continue our correspondence there.

Best regards,

Uros
Hi,
Could you share the answer plz?
thanks.

User avatar
filip.grujcic
Posts: 822
Joined: 14 May 2018 08:34

Re: PIC32MZ SPI - MMC - Problem

#5 Post by filip.grujcic » 19 Oct 2018 13:14

Hi,

I attached an example code for reading from SD card.

Kind regards,
Attachments
mmc_pic32mz.zip
(907.64 KiB) Downloaded 137 times
Filip Grujcic

ahmed.hasib
Posts: 71
Joined: 11 Jul 2015 17:59

Re: PIC32MZ SPI - MMC - Problem

#6 Post by ahmed.hasib » 19 Oct 2018 13:33

Hi Filip,
Thanks a lot, but sorry i use Mikrobasic pro for PIC32.
could you send an example? i checked the examples from the compiler but seems the configurations are not for MZ series.

User avatar
filip.grujcic
Posts: 822
Joined: 14 May 2018 08:34

Re: PIC32MZ SPI - MMC - Problem

#7 Post by filip.grujcic » 22 Oct 2018 15:32

Hello,

I attached the above example in mBasic.

Kind regards,
Attachments
MMC Fat16.zip
(323.29 KiB) Downloaded 98 times
Filip Grujcic

ahmed.hasib
Posts: 71
Joined: 11 Jul 2015 17:59

Re: PIC32MZ SPI - MMC - Problem

#8 Post by ahmed.hasib » 24 Oct 2018 11:56

Hi Filip,
Thank you for your post.
i tried to initialize but failed.
could you check my attached project please?
i use PIC32-HMZ144 development board from Olimex
https://www.olimex.com/Products/PIC/Dev ... e-hardware

SPI2, 2GB fat16 microsd card.
Attachments
PIC32 SD.rar
(320.33 KiB) Downloaded 107 times

ahmed.hasib
Posts: 71
Joined: 11 Jul 2015 17:59

Re: PIC32MZ SPI - MMC - Problem

#9 Post by ahmed.hasib » 26 Oct 2018 08:01

Hi,
Finally Done! it was a configuration problem.
i have a question please:
which way is faster for loading image, from SD card or internal memory?
Thanks.

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: PIC32MZ SPI - MMC - Problem

#10 Post by filip » 29 Oct 2018 09:23

Hi,

I believe you have been answered here :
viewtopic.php?f=97&t=73618

Regards,
Filip.

Post Reply

Return to “mikroC PRO for PIC32 General”