CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

MMC CODE ERROR

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
deltatech



Joined: 22 Apr 2006
Posts: 87

View user's profile Send private message

MMC CODE ERROR
PostPosted: Fri Jun 02, 2006 6:33 pm     Reply with quote

HI I am Using a CCS Prototyping board with a MMC Card Reader So the Hardware should be OK well its made by CCS!

I have tried two different versions of the MMC CODE fromt this forum both of them are not working . The Error for both is same if the card is in or out . The Card is woks fine in a nokia phone also .

So it must be the code Any help wpuld be appriciated .

This code gives the Following error


06/03/2006 01:15:46.015 --> Start\0A
\0A \0D
\0A06/03/2006 01:15:46.046 --> Write Error \0D

http://www.ccsinfo.com/forum/viewtopic.php?t=23183&start=15
Code:
#include "F:\Program Files\PICC\Project\MMC-Code\MMC-WORK\CCS-MMC.h"

//#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
//#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=9)
#use fast_io(C)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
// TEST : using the mmc in write and read mode.
// Based on http://www.ccsinfo.com/forum/viewtopic.php?t=23183

#fuses HS,NOWDT,NOPROTECT,NOLVP
//#fuses HS,NOWDT,NOPUT,NOLVP,NOBROWNOUT,NOCPD,NOWRT
//#use rs232(baud=9600, xmit=PIN_E1, rcv=PIN_E0,ERRORS)

//#use fast_io(B)
//#use fast_io(C)

#use fast_io(C)
#use fast_io(D)

// For the PIC 18F4520 see manual on page 68/426
#byte SSPBUF = 0xFC9
#byte SSPCON = 0xFC6
#byte SSPSTAT = 0xFC7
#bit  BF = SSPSTAT.0
#bit SMP = SSPSTAT.7
#bit CKE = SSPSTAT.6
#bit CKP = SSPCON.4
#bit SSPM1 = SSPCON.1
#bit SSPEN = SSPCON.5
#byte PORTC = 0xF94
#byte PORTD = 0xF95
#bit CS = PORTD.3
/*

On the Eternet Prototyping Board PIC to MMC PIN Connection
#bit CS = PORTD.3
#bit DIN = PORTC.5
#bit D0 = PORTC.4
#bit CLK = PORTC.3

*/
// Command codes
#define MMC_CMD(x)         (0x40 + x)    // A command always starts with the same two start bits.
#define GO_IDLE_STATE     MMC_CMD(0)    // Reset card to Idle State
#define SEND_OP_COND      MMC_CMD(1)    // Activates the card's initialization process.
#define SEND_STATUS       MMC_CMD(13)   // Asks the card to send its status register
#define READ_SINGLE_BLOCK MMC_CMD(17)   // Reads a block of the size selected with SET_BLOCKLEN
#define WRITE_BLOCK       MMC_CMD(24)   // Writes a block of the size selected with SET_BLOCKLEN

#define MMC_TIME_OUT      0xFF          // Just a long time out value
#define TIMER_EXPIRED     0

// -------------------------------------------------
// This is the same as the CCS spi_read() function.
char SPI(char d)
{
  SSPBUF=d;
  while (!BF);
  return SSPBUF;
}

//-----------------------------------------------------------------------------
// Send a command with parameters to the MultiMediaCard
//-----------------------------------------------------------------------------
int8 Command(int8 Cmd, int8 Param1, int8 Param2, int8 Param3, int8 Param4)
{
  int8 Response;
  int8 TimeOutCounter;

  // Allow at least 8 dummy clocks between commands
  spi_read(0xFF);   // note that the first bit is undefined when card is busy (high impedance state)

  // check for the card not being in busy state.
  TimeOutCounter = MMC_TIME_OUT;
  do
  {
    Response = spi_read(0xFF);
  }
  while ((Response != 0xFF) && (--TimeOutCounter != TIMER_EXPIRED));
  if (TimeOutCounter == TIMER_EXPIRED)
  {
    puts("Time out; card busy.\r\n");
    return 0xFF;
  }

  // Send command to the card
  spi_write(Cmd);         // Command
  spi_write(Param1);      // Parameter 1
  spi_write(Param2);      // Parameter 2
  spi_write(Param3);      // Parameter 3
  spi_write(Param4);        // Parameter 4
  spi_write(0x95);        // CRC (including End Bit)
                          // Hard coded the CRC to 0x95 because CRC is always
                          // don't care except for CMD0 which uses 0x95.

  // Wait for response
  TimeOutCounter = MMC_TIME_OUT;
  do
  {
    Response = spi_read(0xFF);
  }
  while ((Response == 0xFF) && (--TimeOutCounter != TIMER_EXPIRED));

  return Response;
}

// -------------------------------------------------
char MMC_Init()
{
  char i;

  // Init SPI
  SMP=0; CKE=0; CKP=1; SSPM1=1; SSPEN=1; //SSPM0=1;
  CS=1;      // MMC-Disabled

  // MMC in SPI Mode -- start and Reset.
  for(i=0; i < 10; i++) SPI(0xFF);            // 10*8=80 clocks
  CS=0;                                       // MMC-Enabled

  // CMD0
  if (Command(GO_IDLE_STATE, 0,0,0,0) != 1)
    goto Error; // Reset

st:
  // CMD1
  if (Command(SEND_OP_COND, 0,0,0,0) != 0)
    goto st ;   // CMD1

  return 1;

Error:
  return 0;
}

// -------------------------------------------------
void main(void)
{
  int16 i;
  setup_adc_ports(NO_ANALOGS);

  // PIC 18F code
//  set_tris_c(0b01111011);       // sdo=rc7(pin26)-0, CS=rc2(pin17)-0.
 // set_tris_b(0b00000000);       // sck=rb1(pin34)-0, sdi=rb0(pin33)-I

//PIC 18F4520
       // sdo=rc7(pin26)-0, CS=rc2(pin17)-0.
set_tris_d(0b00000000);
  set_tris_c(0b00010000);


  puts("Start\n\r");
  if(MMC_Init())
    puts("MMC ON - Init OK\n\r");       // MMC Init OK

  // -------------------------------------------------
  // Write block
  if (Command(WRITE_BLOCK, 0,0,2,0) != 0)
    puts("Write error in begin of write"); // Write in 512 Byte-Mode
  else
  {
    SPI(0xFF);              // Wait a minimum of 8 clock pulses
    SPI(0xFE);              // Write the Start Block Token (0xFE)

    SPI("Begin\n\r");       // 7 characters
    for(i=0; i < 500; i++)  // Was 512, but used 12 for text
      SPI('M');
    SPI("\n\rEnd");         // 5 characters


    SPI(0xFF);              // Write the 16-bit CRC at the end (don't cares)
    SPI(0xFF);

    i = SPI(0xFF);          // Get data response token
    i &= 0b00011111;
    if (i != 0b00000101)
    {
      i = Command(SEND_STATUS, 0,0,0,0);
      printf("Write Error in end of write (status: 0x%X)\n", i);
    }
    while(SPI(0xFF) != 0xFF)
      ; // Wait for end of Busy condition
  }

  // -------------------------------------------------
  // Read in 512 Byte-Mode
  if (Command(READ_SINGLE_BLOCK, 0,0,2,0) !=0)
    puts("Read Error ");
  else
  {
    while(SPI(0xFF) != 0xFE);
    for(i=0; i < 512; i++)
      putc(SPI(0xFF));       // Send data
    SPI(0xFF);     // Send two bytes of 0xFF at the end
    SPI(0xFF);
  }
  while(1);       // The program stops here.
}


With The Other version i get the following error

06/03/2006 01:27:19.750 --> Start\0A
\0A \0D
\0A06/03/2006 01:27:19.750 --> Time out; card busy.\0D \0A\0D
\0A06/03/2006 01:27:19.781 --> Time out; card busy.\0D \0A\0D
\0A06/03/2006 01:27:19.796 --> Write error in begin of write\0D \0A06/03/2006 01:27:19.843 --> Time out; card busy.\0D \0A\0D
\0A06/03/2006 01:27:19.875 --> Read Error \0D


Code:
#include "F:\Program Files\PICC\Project\MMC-Code\MMC-WORK\CCS-MMC.h"

//#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
//#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=9)
#use fast_io(C)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
// TEST : using the mmc in write and read mode.
// Based on http://www.ccsinfo.com/forum/viewtopic.php?t=23183

#fuses HS,NOWDT,NOPROTECT,NOLVP
//#fuses HS,NOWDT,NOPUT,NOLVP,NOBROWNOUT,NOCPD,NOWRT
//#use rs232(baud=9600, xmit=PIN_E1, rcv=PIN_E0,ERRORS)

//#use fast_io(B)
//#use fast_io(C)

#use fast_io(C)
#use fast_io(D)

// For the PIC 18F4520 see manual on page 68/426
#byte SSPBUF = 0xFC9
#byte SSPCON = 0xFC6
#byte SSPSTAT = 0xFC7
#bit  BF = SSPSTAT.0
#bit SMP = SSPSTAT.7
#bit CKE = SSPSTAT.6
#bit CKP = SSPCON.4
#bit SSPM1 = SSPCON.1
#bit SSPEN = SSPCON.5
#byte PORTC = 0xF94
#byte PORTD = 0xF95
#bit CS = PORTD.3
/*

On the Eternet Prototyping Board PIC to MMC PIN Connection
#bit CS = PORTD.3
#bit DIN = PORTC.5
#bit D0 = PORTC.4
#bit CLK = PORTC.3

*/
// Command codes
#define MMC_CMD(x)         (0x40 + x)    // A command always starts with the same two start bits.
#define GO_IDLE_STATE     MMC_CMD(0)    // Reset card to Idle State
#define SEND_OP_COND      MMC_CMD(1)    // Activates the card's initialization process.
#define SEND_STATUS       MMC_CMD(13)   // Asks the card to send its status register
#define READ_SINGLE_BLOCK MMC_CMD(17)   // Reads a block of the size selected with SET_BLOCKLEN
#define WRITE_BLOCK       MMC_CMD(24)   // Writes a block of the size selected with SET_BLOCKLEN

#define MMC_TIME_OUT      0xFF          // Just a long time out value
#define TIMER_EXPIRED     0

// -------------------------------------------------
// This is the same as the CCS spi_read() function.
char SPI(char d)
{
  SSPBUF=d;
  while (!BF);
  return SSPBUF;
}

//-----------------------------------------------------------------------------
// Send a command with parameters to the MultiMediaCard
//-----------------------------------------------------------------------------
int8 Command(int8 Cmd, int8 Param1, int8 Param2, int8 Param3, int8 Param4)
{
  int8 Response;
  int8 TimeOutCounter;

  // Allow at least 8 dummy clocks between commands
  spi_read(0xFF);   // note that the first bit is undefined when card is busy (high impedance state)

  // check for the card not being in busy state.
  TimeOutCounter = MMC_TIME_OUT;
  do
  {
    Response = spi_read(0xFF);
  }
  while ((Response != 0xFF) && (--TimeOutCounter != TIMER_EXPIRED));
  if (TimeOutCounter == TIMER_EXPIRED)
  {
    puts("Time out; card busy.\r\n");
    return 0xFF;
  }

  // Send command to the card
  spi_write(Cmd);         // Command
  spi_write(Param1);      // Parameter 1
  spi_write(Param2);      // Parameter 2
  spi_write(Param3);      // Parameter 3
  spi_write(Param4);        // Parameter 4
  spi_write(0x95);        // CRC (including End Bit)
                          // Hard coded the CRC to 0x95 because CRC is always
                          // don't care except for CMD0 which uses 0x95.

  // Wait for response
  TimeOutCounter = MMC_TIME_OUT;
  do
  {
    Response = spi_read(0xFF);
  }
  while ((Response == 0xFF) && (--TimeOutCounter != TIMER_EXPIRED));

  return Response;
}

// -------------------------------------------------
char MMC_Init()
{
  char i;

  // Init SPI
  SMP=0; CKE=0; CKP=1; SSPM1=1; SSPEN=1; //SSPM0=1;
  CS=1;      // MMC-Disabled

  // MMC in SPI Mode -- start and Reset.
  for(i=0; i < 10; i++) SPI(0xFF);            // 10*8=80 clocks
  CS=0;                                       // MMC-Enabled

  // CMD0
  if (Command(GO_IDLE_STATE, 0,0,0,0) != 1)
    goto Error; // Reset

st:
  // CMD1
  if (Command(SEND_OP_COND, 0,0,0,0) != 0)
    goto st ;   // CMD1

  return 1;

Error:
  return 0;
}

// -------------------------------------------------
void main(void)
{
  int16 i;
  setup_adc_ports(NO_ANALOGS);

  // PIC 18F code
//  set_tris_c(0b01111011);       // sdo=rc7(pin26)-0, CS=rc2(pin17)-0.
 // set_tris_b(0b00000000);       // sck=rb1(pin34)-0, sdi=rb0(pin33)-I

//PIC 18F4520
       // sdo=rc7(pin26)-0, CS=rc2(pin17)-0.
set_tris_d(0b00000000);
  set_tris_c(0b00010000);


  puts("Start\n\r");
  if(MMC_Init())
    puts("MMC ON - Init OK\n\r");       // MMC Init OK

  // -------------------------------------------------
  // Write block
  if (Command(WRITE_BLOCK, 0,0,2,0) != 0)
    puts("Write error in begin of write"); // Write in 512 Byte-Mode
  else
  {
    SPI(0xFF);              // Wait a minimum of 8 clock pulses
    SPI(0xFE);              // Write the Start Block Token (0xFE)

    SPI("Begin\n\r");       // 7 characters
    for(i=0; i < 500; i++)  // Was 512, but used 12 for text
      SPI('M');
    SPI("\n\rEnd");         // 5 characters


    SPI(0xFF);              // Write the 16-bit CRC at the end (don't cares)
    SPI(0xFF);

    i = SPI(0xFF);          // Get data response token
    i &= 0b00011111;
    if (i != 0b00000101)
    {
      i = Command(SEND_STATUS, 0,0,0,0);
      printf("Write Error in end of write (status: 0x%X)\n", i);
    }
    while(SPI(0xFF) != 0xFF)
      ; // Wait for end of Busy condition
  }

  // -------------------------------------------------
  // Read in 512 Byte-Mode
  if (Command(READ_SINGLE_BLOCK, 0,0,2,0) !=0)
    puts("Read Error ");
  else
  {
    while(SPI(0xFF) != 0xFE);
    for(i=0; i < 512; i++)
      putc(SPI(0xFF));       // Send data
    SPI(0xFF);     // Send two bytes of 0xFF at the end
    SPI(0xFF);
  }
  while(1);       // The program stops here.
}
                                   
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Jun 03, 2006 12:39 am     Reply with quote

I looked up a couple of the addresses in the following list,
and they're wrong.
Quote:

// For the PIC 18F4520 see manual on page 68/426
#byte SSPBUF = 0xFC9
#byte SSPCON = 0xFC6
#byte SSPSTAT = 0xFC7
#bit BF = SSPSTAT.0
#bit SMP = SSPSTAT.7
#bit CKE = SSPSTAT.6
#bit CKP = SSPCON.4
#bit SSPM1 = SSPCON.1
#bit SSPEN = SSPCON.5
#byte PORTC = 0xF94
#byte PORTD = 0xF95
#bit CS = PORTD.3


You have this:
Quote:
#byte PORTC = 0xF94
#byte PORTD = 0xF95

In fact, those are the TRIS register addresses.

The addresses of PORTC and PORTD are 0xF82 and 0xF83, respectively.
Details are important. See this section in the 18F4520 data sheet:
Quote:
TABLE 5-1: SPECIAL FUNCTION REGISTER MAP FOR PIC18F2420/2520/4420/4520 DEVICES

I didn't check the rest of the list. You need to check it.
deltatech



Joined: 22 Apr 2006
Posts: 87

View user's profile Send private message

MMC CODE ERROR
PostPosted: Sat Jun 03, 2006 7:44 am     Reply with quote

Thanks PCMPROGRAMMER For your Advice I have changed Port C and Port D address . But I still get the same error.

06/03/2006 14:41:23.265 --> Start\0A
\0A \0D
\0A06/03/2006 14:41:23.281 --> Time out; card busy.\0D
\0A\0D
\0A06/03/2006 14:41:23.328 --> Time out; card busy.\0D
\0A\0D
\0A06/03/2006 14:41:23.343 --> Write error in begin of write\0D
\0A06/03/2006 14:41:23.390 --> Time out; card busy.\0D
\0A\0D
\0A06/03/2006 14:41:23.421 --> Read Error \0D



I have noticed one thing on Page 63 Datasheet 18f4420

SSPCON is listed as [b]SSPCON1 [/b] . However if i change this to SSPCON the compliler doesnt like it .

Code:
#include "F:\Program Files\PICC\Project\MMC-Code\MMC-WORK\CCS-MMC.h"

//#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
//#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=9)
#use fast_io(C)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
// TEST : using the mmc in write and read mode.
// Based on http://www.ccsinfo.com/forum/viewtopic.php?t=23183

#fuses HS,NOWDT,NOPROTECT,NOLVP
//#fuses HS,NOWDT,NOPUT,NOLVP,NOBROWNOUT,NOCPD,NOWRT
//#use rs232(baud=9600, xmit=PIN_E1, rcv=PIN_E0,ERRORS)

//#use fast_io(B)
//#use fast_io(C)

#use fast_io(C)
#use fast_io(D)

// For the PIC 18F4520 see manual on page 68/426
#byte SSPBUF = 0xFC9
#byte SSPCON = 0xFC6
#byte SSPSTAT = 0xFC7
#bit  BF = SSPSTAT.0
#bit SMP = SSPSTAT.7
#bit CKE = SSPSTAT.6
#bit CKP = SSPCON.4
#bit SSPM1 = SSPCON.1
#bit SSPEN = SSPCON.5
#byte PORTC = 0xF82
#byte PORTD = 0xF83
#bit CS = PORTD.3


/*

On the Eternet Prototyping Board PIC to MMC PIN Connection
#bit CS = PORTD.3
#bit DIN = PORTC.5
#bit D0 = PORTC.4
#bit CLK = PORTC.3

*/
// Command codes
#define MMC_CMD(x)         (0x40 + x)    // A command always starts with the same two start bits.
#define GO_IDLE_STATE     MMC_CMD(0)    // Reset card to Idle State
#define SEND_OP_COND      MMC_CMD(1)    // Activates the card's initialization process.
#define SEND_STATUS       MMC_CMD(13)   // Asks the card to send its status register
#define READ_SINGLE_BLOCK MMC_CMD(17)   // Reads a block of the size selected with SET_BLOCKLEN
#define WRITE_BLOCK       MMC_CMD(24)   // Writes a block of the size selected with SET_BLOCKLEN

#define MMC_TIME_OUT      0xFF          // Just a long time out value
#define TIMER_EXPIRED     0

// -------------------------------------------------
// This is the same as the CCS spi_read() function.
char SPI(char d)
{
  SSPBUF=d;
  while (!BF);
  return SSPBUF;
}

//-----------------------------------------------------------------------------
// Send a command with parameters to the MultiMediaCard
//-----------------------------------------------------------------------------
int8 Command(int8 Cmd, int8 Param1, int8 Param2, int8 Param3, int8 Param4)
{
  int8 Response;
  int8 TimeOutCounter;

  // Allow at least 8 dummy clocks between commands
  spi_read(0xFF);   // note that the first bit is undefined when card is busy (high impedance state)

  // check for the card not being in busy state.
  TimeOutCounter = MMC_TIME_OUT;
  do
  {
    Response = spi_read(0xFF);
  }
  while ((Response != 0xFF) && (--TimeOutCounter != TIMER_EXPIRED));
  if (TimeOutCounter == TIMER_EXPIRED)
  {
    puts("Time out; card busy.\r\n");
    return 0xFF;
  }

  // Send command to the card
  spi_write(Cmd);         // Command
  spi_write(Param1);      // Parameter 1
  spi_write(Param2);      // Parameter 2
  spi_write(Param3);      // Parameter 3
  spi_write(Param4);        // Parameter 4
  spi_write(0x95);        // CRC (including End Bit)
                          // Hard coded the CRC to 0x95 because CRC is always
                          // don't care except for CMD0 which uses 0x95.

  // Wait for response
  TimeOutCounter = MMC_TIME_OUT;
  do
  {
    Response = spi_read(0xFF);
  }
  while ((Response == 0xFF) && (--TimeOutCounter != TIMER_EXPIRED));

  return Response;
}

// -------------------------------------------------
char MMC_Init()
{
  char i;

  // Init SPI
  SMP=0; CKE=0; CKP=1; SSPM1=1; SSPEN=1; //SSPM0=1;
  CS=1;      // MMC-Disabled

  // MMC in SPI Mode -- start and Reset.
  for(i=0; i < 10; i++) SPI(0xFF);            // 10*8=80 clocks
  CS=0;                                       // MMC-Enabled

  // CMD0
  if (Command(GO_IDLE_STATE, 0,0,0,0) != 1)
    goto Error; // Reset

st:
  // CMD1
  if (Command(SEND_OP_COND, 0,0,0,0) != 0)
    goto st ;   // CMD1

  return 1;

Error:
  return 0;
}

// -------------------------------------------------
void main(void)
{
  int16 i;
  setup_adc_ports(NO_ANALOGS);

  // PIC 18F code
//  set_tris_c(0b01111011);       // sdo=rc7(pin26)-0, CS=rc2(pin17)-0.
 // set_tris_b(0b00000000);       // sck=rb1(pin34)-0, sdi=rb0(pin33)-I

//PIC 18F4520
       // sdo=rc7(pin26)-0, CS=rc2(pin17)-0.
set_tris_d(0b00000000);
  set_tris_c(0b00010000);


  puts("Start\n\r");
  if(MMC_Init())
    puts("MMC ON - Init OK\n\r");       // MMC Init OK

  // -------------------------------------------------
  // Write block
  if (Command(WRITE_BLOCK, 0,0,2,0) != 0)
    puts("Write error in begin of write"); // Write in 512 Byte-Mode
  else
  {
    SPI(0xFF);              // Wait a minimum of 8 clock pulses
    SPI(0xFE);              // Write the Start Block Token (0xFE)

    SPI("Begin\n\r");       // 7 characters
    for(i=0; i < 500; i++)  // Was 512, but used 12 for text
      SPI('M');
    SPI("\n\rEnd");         // 5 characters


    SPI(0xFF);              // Write the 16-bit CRC at the end (don't cares)
    SPI(0xFF);

    i = SPI(0xFF);          // Get data response token
    i &= 0b00011111;
    if (i != 0b00000101)
    {
      i = Command(SEND_STATUS, 0,0,0,0);
      printf("Write Error in end of write (status: 0x%X)\n", i);
    }
    while(SPI(0xFF) != 0xFF)
      ; // Wait for end of Busy condition
  }

  // -------------------------------------------------
  // Read in 512 Byte-Mode
  if (Command(READ_SINGLE_BLOCK, 0,0,2,0) !=0)
    puts("Read Error ");
  else
  {
    while(SPI(0xFF) != 0xFE);
    for(i=0; i < 512; i++)
      putc(SPI(0xFF));       // Send data
    SPI(0xFF);     // Send two bytes of 0xFF at the end
    SPI(0xFF);
  }
  while(1);       // The program stops here.
}

ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Sat Jun 03, 2006 8:13 am     Reply with quote

Quote:
I have noticed one thing on Page 63 Datasheet 18f4420

A few days ago in thread http://www.ccsinfo.com/forum/viewtopic.php?t=27180 you wrote
Quote:
I am Using CCS Ethernet Prototyping board
Which to my understanding contains an 18F4520

Then in a Private email you send me
Code:
#include <18F4620.h>


The 4420 and 4520 are described in the same datasheet, but the 4620 is from another family.
Can please check out the processor type on your hardware, mention it to us and then stick to it?

Development is in the small details...
deltatech



Joined: 22 Apr 2006
Posts: 87

View user's profile Send private message

MMC CODE ERROR
PostPosted: Sat Jun 03, 2006 9:16 am     Reply with quote

HI Yes on the Board it say 18F4520 . But when i complile it the ICD-U40 comes up whith a message the Processer is 18F4620 .

And I selected 18F4620 . and it compiles . So i dont know whats going on . They may have changed the PIC in manufacturing .
deltatech



Joined: 22 Apr 2006
Posts: 87

View user's profile Send private message

MMc Code Error
PostPosted: Sat Jun 03, 2006 9:22 am     Reply with quote

Infact I have checked it on the PIC it says 18F4620 . so they have changed the chip in Manufacture .
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Sat Jun 03, 2006 6:12 pm     Reply with quote

You are using my Command() function as posted in the thread http://www.ccsinfo.com/forum/viewtopic.php?p=53447. This function is working in my own program but when I posted it I never tried it in combination with the other routines from that thread. Bart said about this:
Quote:
PS : ckielstra : can't manage to let it work with yours. I think something is missing. Thanks anyway for your help.
So it isn't a great surprise this function isn't working for you either.

I could spend some time trying to figure out what the error is, but I don't have a test system at home and to be frank I don't want to. The program as given here has many flaws and is not easy to port to other PIC processors (look at how much time you spend). The biggest flaw is setting the CS line only once and then never releasing it, according to the MMC specifications the CS line should be toggled between all commands.

I recommend you try another MMC driver, for example:
- The CCS supplied driver mmc_spi.c in the drivers directory of your compiler.
- A FAT16 file system in the Code Library: http://www.ccsinfo.com/forum/viewtopic.php?t=21721
deltatech



Joined: 22 Apr 2006
Posts: 87

View user's profile Send private message

PostPosted: Sun Jun 04, 2006 7:43 am     Reply with quote

Thanks ckeistra for your advice i will look try the ccs mmc driver . and see how it goes .
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group