Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

proteus MMC image file help ?

Status
Not open for further replies.

drdigital

Junior Member level 3
Junior Member level 3
Joined
Apr 13, 2009
Messages
31
Helped
5
Reputation
10
Reaction score
4
Trophy points
1,288
Visit site
Activity points
1,525
multimedia card image file

Hi All,

I want to know how to make a .mmc image file to insert it in a proteus simualtion

Thanks
 

mmc image file

you can use WinHex software.

if you just want a blank MMC file (for simulation purpose),
you can create a blank text file, then just rename it, for example, to "blank.mmc"
 
proteus mmc

No I don't want it blank. I want to format .. store data .. and read it.

I didn't know how to use WinHex for that.Can you tell me how please ?
 

proteus mmc image

Hi everybody:
I want to connect a multimedia card (mmc) to atmega16 avr in proteus.Could anybody please tell me what "mmc image file" is ?
 

mmc card image file

mmc image file is the image file you want to load in the card
 

    luna_tic

    Points: 2
    Helpful Answer Positive Rating
    V

    Points: 2
    Helpful Answer Positive Rating

    Mjarrah

    Points: 2
    Helpful Answer Positive Rating
proteus card image file

nssr.smdzdh said:
Hi everybody:
I want to connect a multimedia card (mmc) to atmega16 avr in proteus.Could anybody please tell me what "mmc image file" is ?
could u explain more?how can i produce it?
 

cardimage.mmc

here the full simulation of mmc on proteus
from ur new friend thunder from egypt
 
proteus mmc card image file

Here is a complete working code for MMC read and write operations for ATmega32.It is simulated in Proteus VSM:

Code:
////////////////////////////////////////////////////////////////////////////////
//ICC-AVR application builder : 1/21/2007 12:37:44 AM
// Target : M32
// Crystal: 11.059Mhz
////////////////////////////////////////////////////////////////////////////////

#include <iom32v.h>
#include <macros.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

#define SPIDDR  DDRB
#define SPIPORT PORTB
#define SPIPIN  PINB
#define CS      0x10
#define BinToASCII(t) ((t<=9) ? (t|0x30):(t+55))
#define ASCIIToBin(t) ((t>='A'&& t<='F')?t-55:((t>='0'&& t<='9') ? t-'0':0))
#define BYTELOW(v)  (*((unsigned char *)(&v))) 
#define BYTEHIGH(v) (*(((unsigned char *)(&v) + 1)))
#define BLOCK_SIZE	512	

const unsigned char  CMD0_RST_IDLE[]= {0x40,0x00,0x00,0x00,0x00,0x95};
					 //command 0 reset all card to idle state	
const unsigned char	 CMD1_SND_OPCND[]= {0x41,0x00,0x00,0x00,0x00,0xFF};
					 //command 1 for read OPERATION CONDITION register 
const unsigned char	 CMD16_SET_BLOCKLEN[]= {0x50,0x00,0x00,0x02,0x00,0xFF};
	  		   		 //command 16 TO SET BLOCK LENGHT=512 BYTE TO READ & WRITE
					 //0x000200=512 & 0x00000010=16
const unsigned char	MSGF[] ={"\rMMC CARD INTERFACE\r"};
const unsigned char	MSG0[] ={"\rMMC CARD COMMAND 0\r"};
const unsigned char	MSG1[] ={"\rMMC CARD COMMAND 1\r"};
const unsigned char	MSGB[] ={"\rMMC CARD COMMAND BLOCK=512\r"};
const unsigned char	MSGW[] ={"\rMMC CARD SECTOR WRITE\r"};
const unsigned char	MSGR[] ={"\rMMC CARD SECTOR READ\r"};
const unsigned char	MSG[]  ={"\nMMC CARD IS INITIALIZED SPI MODE\n"};
const unsigned char	CSD[]  ={"\rCSD INFORMATION:\r"};	
const unsigned char	CID[]  ={"\rCID INFORMATION:\r"};
const unsigned char	WACK[] ={"\rWRITE ACKNOLEDGE:\r"};
const unsigned char	WNFSH[]={"\rWRITE NOT FINISH:\r"};
unsigned char TEMP;
unsigned int iSIZE;
unsigned int iSIZE1;
unsigned char BUFFER[128];


unsigned char adc_low,adc_high;
unsigned int timer0_counter=0;

unsigned char Data=65;

unsigned int RdFlag=0,WrtFlag=0;

/******************************************************************************/
/////////****************** Port initialisation ************************////////
/******************************************************************************/

void port_init(void)
{
 	 PORTA = 0x80; // ADC7,for PORTA0 {DDXn,PORTXn,PUD}=010,PXn will source current if Ext. pulled low
 	 DDRA  = 0x00; // PA0-PA3 are used as command lines from host controller  
 	 PORTB = 0xFF; // if DDXn is written logic zero ,the PXn is configured as an i/p
 	 DDRB  = 0xFF;
 	 PORTC = 0x00; //m103 output only
     DDRC  = 0x0F; //LEDs are connected to PORTC0 to PORTC3
 	 PORTD = 0x00;
   	 DDRD  = 0x02;// read/write buttons are connected to portD
}

//UART0 initialize
// desired baud rate: 57600
/* ************************************************************************ */

void uart0_init(void)
{
 UCSRB = 0x00; //disable while setting baud rate
 UCSRA = 0x00;
 UCSRC = BIT(URSEL) | 0x06;
 UBRRL = 0x0B; //set baud rate lo
 UBRRH = 0x00; //set baud rate hi
 UCSRB = 0x18;
}

////////////////////////////////////////////////////////////////////////////////
// 					     SPI port initilaisation                              //                      
////////////////////////////////////////////////////////////////////////////////

void SpiInit()
{
	  DDRB = 0xB0;   // Set SCK, MOSI & SS as outputs
	  SPCR = 0x53;
	  PORTB = 0xEF;  // clear bits MOSI, & SCK      
}


///////////////////////// UART data receive routine //////////////////////////
unsigned char ReceiveByte(void)
{
	  while(!(UCSRA & BIT(RXC)));
	  return UDR;
}
///////////////////////// UART data transmit routine //////////////////////////
void SEND_CHAR_UART(char ch)
{
      while(!(UCSRA & BIT(UDRE))) ;
      UDR = ch;
}

void SendStr(const char *ch)
{
      while(*ch != 0x00) 
	  SEND_CHAR_UART(*ch++);
}
/*------------------------------------*/
void PRINT_ASCII (unsigned char PRNT)
{
	  unsigned char PRN=0;
	  PRN=PRNT>>4; 
 	  SEND_CHAR_UART(BinToASCII(PRN));  
      PRN=PRNT&0x0F;
	  SEND_CHAR_UART(BinToASCII(PRN));  	  
} 

/***  SpiWriteByte() writes a byte to the SPI and waits until  
it has been transmitted.This function doesn't  return any value back.**/
unsigned char CHAR_SPI(unsigned char byte)
{
	  SPDR = byte;
      while (!(SPSR & 0x80));
	  return SPDR;
}
//**************************************
// void Delay_1ms(void)
//**************************************
void Delay_1ms(int Del)
{
	  int i;
 	  while(Del--)
      {  
	  		for (i=0;i<200;i++) 
		  	WDR();
	  }
}
//-----------------------------------------------------------------//
//					 MMC GET RESPONSE							   //	 
//-----------------------------------------------------------------//
unsigned char MMC_RESPONCE(unsigned char RESPONSE )
{
		unsigned int COUNT=0xFFF; // for 64 MB card 
 		//unsigned int COUNT=0xFFFF;  // for 1 GB
		unsigned  char  RESULT;
		while(COUNT!=0)
		{
			  RESULT = CHAR_SPI(0xFF);
    		  // PRINT_ASCII (RESULT);	 SEND_CHAR_UART('\r');	//debug
		 	  if(RESULT==RESPONSE)
			  break;
			  COUNT--;
		}
		if(COUNT==0)return 1;
		else	
	    return 0;
}
/***************************************************/  
unsigned char MMC_WAIT_FOR_WRITE_FINISH( void ) 
{ 
		unsigned char LPCNT=0xFF;
		unsigned char  RESULT = 0;
		/* The delay is set to maximum considering the longest data block length to handle */
  		while( (RESULT == 0) && LPCNT ) 
 		{ 
		         RESULT = CHAR_SPI( 0XFF);
		  		 LPCNT--;
		}
		if (LPCNT== 0 ) 
   		return 1;    	 /* Failure, loop was exited due to timeout */ 
		else return 0;  /* Normal , loop was exited before timeout */
}
/*-----------------------------------------------------------------------------*/  
unsigned char  MMC_INIT()
{
        unsigned char LPCNT=0;
		/* start off with 80 bits of high data with card deselected */
		SPIPORT |=CS; 
		for(LPCNT=0;LPCNT<10; LPCNT++)
		CHAR_SPI(0xff);
/*-----------------------------------------CMD 0-------------------------------*/		 
		SPIPORT &= ~CS;        /* select card */
		CHAR_SPI( 0X40);CHAR_SPI( 0X00);CHAR_SPI( 0X00);
		CHAR_SPI( 0X00);CHAR_SPI( 0X00);CHAR_SPI( 0X95);
		 
		if( (MMC_RESPONCE(0x01)) == 1 )
		{
			SPIPORT |=CS;
			return 1;
		}
		SendStr( MSG0);
/*-----------------------------------------------------------------------------*/ 
 	    SPIPORT |= CS;
	    CHAR_SPI(0xFF); 
/*----------------------------------CMD1---------------------------------------*/ 
	    SPIPORT &= ~CS;   
	    LPCNT=0xFF;
	    do
	    {
			   CHAR_SPI( 0X41);   CHAR_SPI( 0X00);     CHAR_SPI( 0X00);
		       CHAR_SPI( 0X00);   CHAR_SPI( 0X00);     CHAR_SPI( 0XFF);
		 	   LPCNT--;
	    } while ( (MMC_RESPONCE(0x00) != 0) && (LPCNT>0) );
		if(LPCNT==0)
		{	  
		     SPIPORT |= CS; 	   
		     return 1;   
		}
		
        SendStr( MSG1);		
/*--------------------------------------------------------------------*/ 
 	    SPIPORT |= CS;
	    CHAR_SPI(0xFF); 
/*---------------------CMD16  SET BLOCK LENGTH------------------------*/ 	 
	
		SPIPORT &= ~CS;        // select card 
		CHAR_SPI( 0X50); CHAR_SPI( 0X00);  CHAR_SPI( 0X00);
		CHAR_SPI( 0X02); CHAR_SPI( 0X00);  CHAR_SPI( 0XFF);
		if( (MMC_RESPONCE(0x00)) == 1 )
		{
			 SPIPORT |=CS;
			 return 1;
		}
        SendStr( MSGB);
        SPIPORT |= CS;
        CHAR_SPI(0xFF); 
		
        return 0;
}    

/*------------------------------------------------------------*/
//unsigned char  MMC_WRITE_BLOCK( unsigned  long SECTOR)
/*----------------------------------------------------------- */
void GET_CSD()
{
		 SPIPORT &= ~CS;  
		 CHAR_SPI( 0x49);   CHAR_SPI( 0x00);     CHAR_SPI( 0X00);
		 CHAR_SPI( 0x00);   CHAR_SPI( 0x00);     CHAR_SPI( 0XFF);
         while ((MMC_RESPONCE(0x00)) == 1);
 	     while( (MMC_RESPONCE(0xFE)) == 1 );
		 for(TEMP=0;TEMP<=35;TEMP++)
		 BUFFER[TEMP]=CHAR_SPI(0xFF);
         SendStr(CSD);
		 for(TEMP=0;TEMP<=15;TEMP++)
		 PRINT_ASCII(BUFFER[TEMP]);
	     SEND_CHAR_UART('\n');
         SPIPORT |= CS;       // Deselect card
}

/*------------------------------------------------------------*/
//void GET_CID()
/*----------------------------------------------------------- */
void GET_CID()
{
		 SPIPORT &= ~CS;       // select card 
		 CHAR_SPI(0x4A); CHAR_SPI(0x00);  CHAR_SPI(0X00);
		 CHAR_SPI(0x00); CHAR_SPI(0x00);  CHAR_SPI(0XFF);
         while ((MMC_RESPONCE(0x00)) == 1);
	     while( (MMC_RESPONCE(0xFE)) == 1 );
		 for(TEMP=0;TEMP<=35;TEMP++)
		 BUFFER[TEMP]=CHAR_SPI(0xFF);
         SendStr(CID);
		 for(TEMP=0;TEMP<=15;TEMP++)
		 PRINT_ASCII(BUFFER[TEMP]); 
         SEND_CHAR_UART('\n');
         SPIPORT |= CS;       // Deselect card
  
}

/*----------------------------------------------------*/
void INSULATOR()
{ 
     CHAR_SPI( 0xFF);CHAR_SPI( 0xFF);CHAR_SPI( 0xFF);
	 CHAR_SPI( 0xFF);CHAR_SPI( 0xFF);CHAR_SPI( 0xFF);
	 CHAR_SPI( 0xFF);CHAR_SPI( 0xFF);CHAR_SPI( 0xFF);
	 CHAR_SPI( 0xFF);CHAR_SPI( 0xFF);CHAR_SPI( 0xFF);
	 CHAR_SPI( 0xFF);CHAR_SPI( 0xFF);CHAR_SPI( 0xFF);
	 CHAR_SPI( 0xFF);CHAR_SPI( 0xFF);CHAR_SPI( 0xFF);
	 CHAR_SPI( 0xFF);CHAR_SPI( 0xFF);
}

/*--------------------------------------------------------------------------------------*/

unsigned char MMC_WRITE_BLOCK( unsigned   int SECTOR)
{

 		 unsigned char WRT=65;// A
		 unsigned int LPCNT=0;
 		 unsigned long ADDRESS=0;
		 ADDRESS=(unsigned long)SECTOR*BLOCK_SIZE;
 	 
/*-----------------------CMD24------------------------------------------------*/		 
		 SPIPORT &= ~CS; 
		 
		 CHAR_SPI( 0x58); 
		 CHAR_SPI (ADDRESS>>24); 		 CHAR_SPI (ADDRESS>>16);
		 CHAR_SPI (ADDRESS>>8);  		 CHAR_SPI (ADDRESS>>0);     
		 CHAR_SPI( 0xFF);

		 
		 	 if( (MMC_RESPONCE(0x00)) == 1 )
			 {
				SPIPORT |=CS;
				return 1;
			  }
		   
		   CHAR_SPI(0xFF); 
		   CHAR_SPI(0xFE);					 //start of DATABLOCK

             			 
			 
			 for(LPCNT=0;LPCNT<512; LPCNT++)
			 { 
			   	 CHAR_SPI(Data);
				 //CHAR_SPI(WRT);
				 //SEND_CHAR_UART(WRT);
			 }
			 
			 
		   CHAR_SPI(0xFF); CHAR_SPI(0xFF);   // dummy chksum
		   
		   
		 LPCNT= CHAR_SPI(0xFF); 
		 
		 //SendStr(WACK);	PRINT_ASCII(LPCNT);	PRINT_ASCII((LPCNT & 0x0F)); // disabled for debugging 
 		 
		 if ( (LPCNT & 0x0F) != 0x05 )
	 		{
						SPIPORT |=CS;
						return 1;
			}
				
                   if( MMC_WAIT_FOR_WRITE_FINISH()==1)  //disabled for debugging
				    {
				   	   		SendStr(WNFSH); // disabled for debugging           //-----------------------
				   	 		SPIPORT |=CS;
				    		    return 1;
                    }
//SendStr( MSGW); //disabled for debugging
/*----------------------------------------------------------------------------------------------------*/
SPIPORT |= CS;
CHAR_SPI(0xFF);  
return 0;
}    
/*----------------------------------------------------------------------------------------------------*/
unsigned char  MMC_READ_BLOCK( unsigned long SECTOR)
{

unsigned int LPCNT=0;
unsigned long ADDRESS=0;
unsigned char mmcData=0;

ADDRESS=(unsigned long)SECTOR*BLOCK_SIZE;
 
		 
/*-----------------------CMD17------------------------------------------------*/		 
// CMD17 READ_SINGLE_BLOCK
// Function : Single block read  
// [31:0] Data address R1

		 SPIPORT &= ~CS; // Deslect Card
		 
		 CHAR_SPI( 0x51); 
		 
		 CHAR_SPI (ADDRESS>>24); 		 CHAR_SPI (ADDRESS>>16);
		 CHAR_SPI (ADDRESS>>8);  		 CHAR_SPI (ADDRESS>>0);     
		 
		 CHAR_SPI( 0xFF);

		 	 if( (MMC_RESPONCE(0x00)) == 1 )
			 {  SPIPORT |= CS;
				return 1;
			 }
			 
			 //////////////////////////////////////////////////////////////////
             
			 //while( (MMC_RESPONCE(0xFE)) == 1 ) // disabled for debugging
			 //SEND_CHAR_UART('r');               // disabled for debugging
			 
			 //////////////////////////////////////////////////////////////////
			 	
			 
			 while( (MMC_RESPONCE(0xFE)) == 1 ); // added for debugging         //---------
			
			
			 for(LPCNT=0;LPCNT<512;LPCNT++)
			 {
			      
						
						if((LPCNT%32)==0){SEND_CHAR_UART('\n');SEND_CHAR_UART('\r');} 
						
						mmcData=CHAR_SPI(0xFF);
						SEND_CHAR_UART(mmcData); // added for debugging
				  		 
			  }	
			 	 			 

			CHAR_SPI(0xFF);  CHAR_SPI(0xFF);  //read CHKSUM
//SendStr( MSGR); // disabled for debugging
/*----------------------------------------------------------------------------*/
 SPIPORT |= CS; // deslect card
 CHAR_SPI(0xFF);  

return 0;

}    						

//call this routine to initialize all peripherals
void init_devices(void)
{
         CLI(); //disable all interrupts
 	     port_init();
	     uart0_init(); // for baud rate of 115200 bps
	     MCUCR = 0x00; // may be disabled for debugging?????
 	     GICR  = 0x00;
 	     TIMSK = (1<<TOIE0);//timer interrupt sources-timer0
 	     SEI(); //re-enable interrupts
 	     //all peripherals are now initialized}
}
////////////////////////////////////////////////////////////////////////////////
void main(void)
{
   
     int i=0,LPCNT=0;
     unsigned char rData;
     unsigned int SECT=1000;
  
     init_devices(); 
     SpiInit();

////////////////////////////////////////////////////////////////////////////////  
  	 SEND_CHAR_UART(0x0D);
  	 SEND_CHAR_UART(0x0A);
  	 SendStr( MSGF);                      // Transmit welcome message.
						           // MSGF[]={"\rMMC CARD INTERFACE \r"};
  	 SEND_CHAR_UART(0x0D);
  	 SEND_CHAR_UART(0x0A);								    
////////////////////////////////////////////////////////////////////////////////
  	 while ( MMC_INIT() != 0);
  	 //{ 
      	   SendStr( MSG);
	  	   //SEND_CHAR_UART(0x0D);
      	   //SEND_CHAR_UART(0x0A);
	  	   //break; disabled for debugging 
  	 //} 	 
  	 SEND_CHAR_UART(0x0D);	
  	 SEND_CHAR_UART(0x0A);	// MSG[]  ={"\nMMC CARD IS INITIALIZED SPI MODE  \n"};

  	 INSULATOR();
 
/*----------------------------------------------------------------------------*/
  	 SPCR  = 0x50;SPSR|=0x01;
/*----------------------------------------------------------------------------*/
  	 GET_CSD();	   	 
  	 INSULATOR(); 
  	 GET_CID();	 	 
  	 INSULATOR(); 

	 RdFlag=0,WrtFlag=1;
  
     //insert your functional code here...
   	 while(1)
   	 {//start of while loop for data read & write
   
   			
			  ////////////////////////// write routine ///////////////////////////
			
			  if(WrtFlag==1)
   			  {//if for write button
              
			        /////////////////////////////////////////////////////
  			        //Routines for writing data
  			     	
					MMC_WRITE_BLOCK(SECT);
					
					INSULATOR();
					Data++;
		          	SECT++; 
		          	if(SECT>=1005)
		          	{				 
				     	SECT=1000;Data=65;
						RdFlag=1,WrtFlag=0;						
		          	}
	
				
  			  }//end of if block for write button
			
 			  ///////////////// end of write routine /////////////////////////////
			
			  if(RdFlag==1)
    		  {
			          //if swicth connected to PD3 closed then read
			          ////////////////////////////////////////////////////////////////////////////
			          // Routine for reading data
	 	          	 MMC_READ_BLOCK(SECT);INSULATOR();				 
					 
				   	  SECT++; 
				   	  if(SECT>=1005)
				   	  {				 
						   SECT=1000;
						   RdFlag=0,WrtFlag=1;
				   	  }
     
	 	   		}// closing bracket of if block for reading data
				CHAR_SPI(0x55); // added for debugging
	   	 
   
     }//ending bracket for while loop for read & write
   
 
}


This code writes and reads data to and from Multimedia Card (MMC) in SPI mode.
The code has been written in ICC AVR


The schematic diagram of the above mentioned code drawn in Protues VSM is given below:






regards
m.yasir
 
proteus mmc card image

Hello!

If you just want to write raw data on the MMC, the above code (posted by
yasir9909) will make it.
Now if you want to read it on a PC, then there are 2 solutions:
- Implement a file system (FAT16 or FAT32) on your microcontroller;
- Use dd (disk dump???, available here) to put the whole card contents
in a PC file.


Dora.

drdigital said:
No I don't want it blank. I want to format .. store data .. and read it.

I didn't know how to use WinHex for that.Can you tell me how please ?
 

proteus 7 multimedia memory card

You are right the above code works for writing raw data on the Multimedia card in
SPI mode.I have used that code to design a speech recorder.
I had recorded speech data on the card and then, on demand, it was transmitted to the PC through serial link.The speech data is saved through Hyper Terminal in a binary file.This binary file is then converted into the wav file for playing the sound recorded on the MMC and sent to the PC after being read from MMC.

Now i have plans for interfacing this MMC with Camera for capturing and storing images on the MMC.

Do you know whether this scheme would also work for storing images captured from camera on the MMC

regards
m.yasir
 

proteus mmc simulation

Hello!

As long as you know what you write to the MMC, anything can work.
It will depend on the camera. Will you use a camera sensor and
some microcontroller (i.e. make your own digital camera)? In this case,
you can write whatever you want to the MMC.

Now if you want to do the opposite: use a regular camera to write a file
and then read this file from a microcontroller, then I guess you will have
to implement a FAT file system. Not very difficult, but it takes a while until
it works well.

And there is something one should be aware about before writing a FAT.
With small microcontrollers (with limited memory), it takes a while to update
the file tables once you wrote data. (FAT tables update, file record update).

Dora.

yasir9909 said:
You are right the above code works for writing raw data on the Multimedia card in
SPI mode.I have used that code to design a speech recorder.
I had recorded speech data on the card and then, on demand, it was transmitted to the PC through serial link.The speech data is saved through Hyper Terminal in a binary file.This binary file is then converted into the wav file for playing the sound recorded on the MMC and sent to the PC after being read from MMC.

Now i have plans for interfacing this MMC with Camera for capturing and storing images on the MMC.

Do you know whether this scheme would also work for storing images captured from camera on the MMC

regards
m.yasir
 

mmc card image proteus

Which file system should be preferrably used i.e. FAT16 or FAT32.I havent worked on FAT system.

As far as i know this system is used in PC by windows and FAT stands for File Allocation Table.

Can you please tell a little bit detail about FAT in context of implementation on MMC

regards
m.yasir
 

mmc card image file proteus

gnem009
please the link doesnot work>>>>>>>>>>>>>>
upload it again please
 

multimedia card image file for proteus

Hey gnem09!
I'm trying to generate a .mmc file with winhex but it doesn't work, becuase winhex generates .bin files, not .mmc
Can you tell help me? I really need to know how to generate this file!!
 

sd_mmc.rar

Hello!

What do you mean by ".mmc file"?
If you explain what exactly you want to do, you will increase your chances
of having a relevant reply.

Dora.

jenny_brain5 said:
Hey gnem09!
I'm trying to generate a .mmc file with winhex but it doesn't work, becuase winhex generates .bin files, not .mmc
Can you tell help me? I really need to know how to generate this file!!
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top