Libstock
It is currently 02 Sep 2014 10:23

All times are UTC + 1 hour




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: MMC PROJECT PROBLEM
PostPosted: 09 Oct 2009 21:55 
Offline

Joined: 09 Oct 2009 17:07
Posts: 8
I HOPE IF I CAN FIND ANY HELP HERE

I MAKE A MMC PROJECT AND MAKE THE SIMULATION AT THE PROTEUS

I COULD WRITE/READ SECTORS FROM THE MMC AND READ THE CID AND CSD REGISTER AND THAT WORK SO VERY GOOD.

BUT WHEN I WRITE THE COMMAND
Mmc_Fat_Init(); DO NOT WORK

AND WHEN I WRITE THE COMMAND
Mmc_Fat_Assign("MIKROELE.TXT",0xA0); I GET WARNING MESSAGE

"STACK OVERFLOW IS FORCING DEVICE RESET"

AND THE MICRO RESET UNLIMITED TIMES

MICROCONTROLLER:PIC18F4520
MIKROC 2009 V250

THE PROGRAM

//***********************************************************
sbit Mmc_Chip_Select at RC2_bit;
sbit Mmc_Chip_Select_Direction at TRISC2_bit;
void main()
{
char error;
trisb=0;portb=0;
SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV64, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_HIGH, _SPI_LOW_2_HIGH);

Mmc_Init();
Mmc_Fat_Init();
Mmc_Fat_Assign("MIKROELE.TXT",0xA0);



}
//***********************************************************


Top
 Profile  
 
 Post subject:
PostPosted: 10 Oct 2009 04:49 
Offline

Joined: 05 Jul 2008 06:05
Posts: 608
Location: Thailand
When you work with FAT you don't need to use the Mmc_Init() command, what is happening with your program is that you initialise the SPI but the Mmc_Init() reinitialises it, after that the Mmc_Fat functions will not work properly.

After you use the Mmc_Fat_Init() command you can then speed up the SPI otherwise the card functions will be very slow...

//***********************************************************
sbit Mmc_Chip_Select at RC2_bit;
sbit Mmc_Chip_Select_Direction at TRISC2_bit;
void main()
{
char error;
trisb=0;portb=0;
SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV64, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_HIGH, _SPI_LOW_2_HIGH);

Mmc_Fat_Init();

// reinitialise SPI1 at higher speed
SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV4, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_HIGH, _SPI_LOW_2_HIGH);

Mmc_Fat_Assign("MIKROELE.TXT",0xA0);

}
//***********************************************************


You should also provide some error checking in case there is a problem with the card, Mmc_Fat_Init() returns 0, 1 or 255 (see help files) depending on the card condition, so you can change your code like this...


SPI1_Init_Advanced(MASTER_OSC_DIV64, DATA_SAMPLE_MIDDLE, CLK_IDLE_LOW, LOW_2_HIGH);

if (!Mmc_Fat_Init()) { //if the initialise was successful
// reinitialise SPI1 at higher speed
SPI1_Init_Advanced(MASTER_OSC_DIV4, DATA_SAMPLE_MIDDLE, CLK_IDLE_LOW, LOW_2_HIGH);
}
else{ //if the initialise was unsuccessful...
// put your error handling code here
}


ST


Top
 Profile  
 
 Post subject:
PostPosted: 10 Oct 2009 10:07 
Offline

Joined: 09 Oct 2009 17:07
Posts: 8
i really thank you mr.Sobrietytest for your repply and your time.
put for sorrow the problem still exist and the stack still over flow and reset the micro, i hope if you have another solution i can do , and thanks again.


Top
 Profile  
 
 Post subject: Re: MMC PROJECT PROBLEM
PostPosted: 08 Jul 2010 08:40 
Offline

Joined: 24 Jun 2009 13:49
Posts: 7
in 18f series, it is need to connect +ve in mclr pin.other wise,proteus (ISIS) shows error msg.
"MCU is reseting.."


Top
 Profile  
 
 Post subject: Re: MMC PROJECT PROBLEM
PostPosted: 08 Jul 2010 15:55 
Offline
mikroElektronika team
User avatar

Joined: 17 Aug 2009 16:51
Posts: 1733
Location: Belgrade
Hello,

First of all, I warmly recommend you to switch over to mikroC PRO for PIC v3.80, in order to be absolutely sure that this is not something compiler-related.
Secondly, in order to help you, I would really need your entire project folder zipped, so I could recreate this error condition and provide you with explanation or workaround.
Although your program should always keep track of stack level utilization, you should know that Stack Overflow Reset can be turned off in Project->Edit Project Windows, where configuration bits are set.

If you want a private investigation, please open a support ticket at http://www.mikroe.com/esupport

Best regards,
Aleksandar

_________________
mikroElektronika Product Manager


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group