All About Circuits Forum  

Go Back   All About Circuits Forum > Software, Microcomputing, and Communications Forums > Embedded Systems and Microcontrollers

Notices

Embedded Systems and Microcontrollers Discussion forum for projects and working with embedded systems and microcontrollers (FPGAs, PICs, AVRs). Get help with hardware issues and embedded programming.

Reply   Post New Thread
 
Thread Tools Display Modes
  #1  
Old 07-23-2008, 06:05 AM
kovendan_23 kovendan_23 is offline
New Member
 
Join Date: Jul 2008
Posts: 4
Send a message via Yahoo to kovendan_23
Wink regarding Interfacing of the MMc card

Sir :
i am interfacing An MMC card with my AT89C51snd2c , i send upto four commandsc to my MMC card , but i didnt get response from the MMC card i.e MMint register is not set and crc and resp bit .

/************************************************** ************************************************** *****/
/* Field Programmable Announcement System */
/* Main.c */
/************************************************** ************************************************** *****/
#include<at8xc51snd2.h>
sbit LED1 = P2^5;
sbit LED2 = P2^6;
void wrtram(char *);
void rdram(char *);
void delay(long int); /*delay routine - (parameter-delay) */
void sndopcmd1(void); /*transmit command to multimedia card: CMD1-"Send_Output_Condition" */
void sndcmd2(void); /*transmit command to multimedia card: CMD1-"Send_Output_Condition" */
void sndrstcmd(void); /*transmit command to multimedia card: CMD1-"Send_Output_Condition" */
void sndcmd3(void);
char MINTSTA;
char code dummy[3] _at_ 0x23;
unsigned char intval; /*global variable to store the MMCINT value at the time of interrupt */
main(void) {
unsigned char xdata a[10];
unsigned long int j,i;

delay(100);
MINTSTA='F';
MMCLK=0x27; /* division factor 40 = 400khz*/ /*Set MMC Clock frequency*/
MMCON2 |= 0x86; /* Set MMCEN, Delay tx=9 MMC clock*/
MMMSK=0x3C ; /*for */
IEN1=0x01; /* enable EMMC, MMC interrupt enable bit */
IEN0=0x80; /* enable EA, Global interrupt enable bit */
IPH0=0x00;
IPH1=0x01; /* Set High priority to MMC interrupt*/
MMCON2 |= 0x60; /* Set Data and Command controller reset bit*/
MMCON2 &= 0x9F; /* Clear Data and Command controller reset bit*/
delay(74);
MMCON0 |= 0x30; /*Set Command transmit pointer and receive pointer reset bit*/
MMCON0 &= 0xCF; /*Clear Command transmit pointer and receive pointer reset bit*/
MMCON0 |= 0xC0; /*Set Data transmit pointer and receive pointer reset bit*/
MMCON0 &= 0x3F; /*Clear Data transmit pointer and receive pointer reset bit*/
//-------------IDLE STATE -----------------//
MMCON1 |= 0x02; /*Set Response enable bit */
MMCON0 |= 0x03; /*48 bit response format and CRC7 enabled*/
MMCMD=0x40; /* Load "CMD0 - Command 0" - go_idle state/Software reset*/
MMCMD=0x00; /*Argument byte 1*/
MMCMD=0x00; /*Argument byte 2*/
MMCMD=0x00; /*Argument byte 2*/
MMCMD=0x00; /*Argument byte 2*/
MMCMD=0x95; /*Argument byte 2*/
MMCON1 |= 0x03; /* Set Command transmission bit*/
MMCON1 &= 0xFC; /* Clear Command transmission bit*/
delay(80);
//-------------IDLE STATE -----------------//


/*for(j=0;j<20;j++)
{
MMCON0 |= 0x03; /*Set Response format bit for 48bit format*/
//MMCON1 |= 0x02; /*Set Response enable bit */
//MMCMD=0x41; /* Load "CMD1 - Command 1" - SEND_OP_COND */
//MMCMD=0x00; /*Argument byte 4 - OCR byte 4 */
//MMCMD=0x00; /*Argument byte 3 - OCR byte 3 - selected voltage range 2.8V to 3.2V */
//MMCMD=0x00; /*Argument byte 2 - OCR byte 2 */
//MMCMD=0x00; /*Argument byte 1 - OCR byte 1 */
//MMCMD=0xFF; /*Checksum is no longer required. Even we always send FF */
//MMCON1 |= 0x03; /* Set Command transmission and response enable bit*/
//MMCON1 &= 0xFC; /* Clear Command tx & Response enable bit. */
//delay(80);
//}*/
/*for(j=0;j<20;j++)
{
MMCON0=0x31; /* Clear CMD TX & RX pointer */
//MMCON1=0x03; /* Command tx enable. */
//MMCON0=0x01; /* Clear CMD TX & RX pointer, 138 bit response & disable CRC */
//MMCON0 |= 0x03; /*Set Response format bit for 48bit format*/
//MMCON1 |= 0x02; /*Set Response enable bit */
//MMCMD=0x42; //SEND CID
//MMCMD=0x00; /* 4 bytes from here is the block length */
//MMCMD=0x00;
//MMCMD=0x00;
//MMCMD=0x00;
//MMCMD=0xFF;/* checksum is no longer required but we always send 0xFF */
//MMCON1 |= 0x03; /* Set Command transmission and response enable bit*/
//MMCON1 &= 0xFC; /* Clear Command tx & Response enable bit. */
//delay(80);
//}

//for data reading //
//MMCON1 &= 0xF7; /*Set datdir=0 for data in read mode */
//if(MMINT==0x10)
//{
//if(MMSTA==0x0c)
// LED1=!LED1;
//}
//for data reading //

i=2;
do
{
//for(j=0;j<0xff;j++)
{
//if(MINTSTA=='F')

sndopcmd1();
LED1=!LED1;
delay(10000);
}
i--;
}
while(MMCMD!=0);
for(j=0;j<200;j++)
{
if(MINTSTA=='T')
{
sndcmd2();

delay(10000);
}
}

for(j=0;j<20;j++)
{
sndcmd3();
LED2=!LED2;
delay(10000);
}
wrtram(&a);
rdram(&a);
while (1) {
}
}
/*----------------------------------------------------------*/
/* FUNCTIONS */
/*------------ for ----------------------------------------------*/
void sndopcmd1(void) {
MMCON0 |= 0x03; /*Set Response format bit for 48bit format*/
MMCON1 |= 0x02; /*Set Response enable bit */
MMCMD=0x41; /* Load "CMD1 - Command 1" - SEND_OP_COND */
MMCMD=0x00; /*Argument byte 4 - OCR byte 4 */
MMCMD=0x00; /*Argument byte 3 - OCR byte 3 - selected voltage range 2.8V to 3.2V */
MMCMD=0x00; /*Argument byte 2 - OCR byte 2 */
MMCMD=0x00; /*Argument byte 1 - OCR byte 1 */
MMCMD=0xFF; /*Checksum is no longer required. Even we always send FF */
MMCON1 |= 0x03; /* Set Command transmission and response enable bit*/
MMCON1 &= 0xFC; /* Clear Command tx & Response enable bit. */
}
void sndcmd2(void) {
MMCON0=0x31; /* Clear CMD TX & RX pointer */
MMCON1=0x03; /* Command tx enable. */
MMCON0=0x01; /* Clear CMD TX & RX pointer, 138 bit response & disable CRC */
MMCMD=0x42; /* SEND_CID */
MMCMD=0x00; /*Argument byte 4 - */
MMCMD=0x00; /*Argument byte 3 - */
MMCMD=0x00; /*Argument byte 2 - */
MMCMD=0x00; /*Argument byte 1 - */
MMCON1=0x00;
}
void sndcmd3(void) {
MMCON0 |= 0x03; /*Set Response format bit for 48bit format*/
MMCON1 |= 0x02; /*Set Response enable bit */
MMCMD=0x50; /* Load "CMD3 - Command 3" - for blocklength select */
MMCMD=0x00; /*Argument byte 4 - OCR byte 4 */
MMCMD=0x02; /*Argument byte 3 - OCR byte 3 - selected voltage range 2.8V to 3.2V */
MMCMD=0x00; /*Argument byte 2 - OCR byte 2 */
MMCMD=0x00; /*Argument byte 1 - OCR byte 1 */
MMCON1 |= 0x03; /* Set Command transmission and response enable bit*/
MMCON1 &= 0xFC; /* Clear Command tx & Response enable bit. */
}

/************************************************** ********************************/
/* MMC interrupt routine */
/*--------------------------------------------------------------------------------*/
/* Vector: 003Bh using register bank 2 */
mmcint() interrupt 7 using 2 {
unsigned char valmmint, valmmsta, cmdres[17],i;
valmmint=MMINT;
valmmsta=MMSTA;

if(MINTSTA=='F'){
if(valmmint >= 0x40){
for(i=0;i<6;i++){
LED2=!LED2;
cmdres[i]=MMCMD;
}
/*Check for the busy bit */
if (cmdres[1]>=0x80){

MINTSTA='T';
}
}
}
else{
if(MINTSTA=='T'){
valmmint=MMINT;
valmmsta=MMSTA;
for (i=0;i<6;i++){
cmdres[i]=MMCMD;
}

MINTSTA='S'; /* Interrup */
}
}
}
/*---------------------------------------------------------------------------------*/
void wrtram (char *pa) {
int i;
for (i=0 ; i<=10; i++) {
*pa=0xAA;
pa++;
}
}
void rdram(char *pb) {
unsigned int i;
unsigned char temp;
for(i=0; i<10 ;i++) {
temp=*pb;
pb++;
}
if(temp==0xAA)
{
LED2=!LED2;
}
}
void delay(long int x) {
long int j;
for(j=0;j<x;j++) {
}
}
/*----------------------------------------------------------*/
Reply With Quote
Reply   Post New Thread

Tags
, ,


Similar Threads
Thread Thread Starter Forum Replies Last Post
Regarding interfacing of MMC card kovendan_23 Embedded Systems and Microcontrollers 4 07-21-2008 07:04 AM
need help for read and write smart card erickoh1985 Embedded Systems and Microcontrollers 2 05-09-2008 01:37 AM
boosting my wifi NIC MiniPCI card mik3ca Radio and Communications 1 03-18-2008 02:38 PM
interfacing microcontroller with PS-2 keyboard praj Embedded Systems and Microcontrollers 1 10-02-2007 01:20 PM

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:26 PM.


User-posted content, unless source quoted, is licensed under a Creative Commons Public Domain License.
Powered by vBulletin
Copyright ©2000 - 2014, vBulletin Solutions, Inc.