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

SD card memory problem
Goto page Previous  1, 2, 3
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
ckielstra



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

View user's profile Send private message

PostPosted: Tue May 14, 2013 12:50 am     Reply with quote

Helping you is difficult for several reasons:
- Your dsPIC33 processor is from a family that only a few people on this forum are using. Heck, most of us don't even have the required PCD compiler, including me.
- Your 4.093 compiler version is old, we are now at v4.141. These 48 releases fixed many problems. Perhaps your compiler is not too old, but v4.104 and 105 did fix some #SPI problems in the PCD compiler and many other PCD related problems have been fixed.
- You didn't post a hardware schematic
- The link to the SD card module does not provide a hardware schematic, this worries me as there are 4 resistors, 4 capacitors and one unknown active component. The 5V connection makes me very suspicious.

So here are a few questions for you:
1) You didn't answer Andrew's question and I would like to know the answer too: did your call to mmcsd_init() return MMCSD_GOODEC?
2) Why do you want to use a dsPIC33? It's a great processor but more difficult to handle than a PIC18 and on this forum there are way less people who can help you.
3) Is your RS232 communication now working stable and without bad characters? Bad characters are an indication of timing problems that will bite you in the other parts of your project.
4) You had to add a resistor to the crystal to make it work? This is not common practice. Again, I'd like to see a schematic if possible.
5) Please post your complete test program, not only the few lines you posted until now. Include the #fuses lines, etc. but do not post the CCS supplied header files.
Jim90



Joined: 27 Apr 2013
Posts: 55

View user's profile Send private message

SD card memory problem
PostPosted: Thu May 16, 2013 8:55 pm     Reply with quote

1)I checked again and, no when i run the code :
Code:


if (mmcsd_init() == MMCSD_GOODEC)
{
  printf(" initialised successfully, proceed");
}
else
{
   printf("didn't initialise, do something else");
}

I receive the message didn't initialise, do something else

2)I would like to learn this microcontroller's series.
3)Firstly i tried the internal oscillator (There was an example in the forum)and this was created problems, so i moved to the external oscillator which is working fine.
4)I didn't know too , but i read it to the datasheet.
5)This is the code which i used. (I followed an example from the forum, so i believe that The fuses,... are ok):


Code:

#include <33fj128GP202.h>
#include <stdlib.h>

#fuses HS, NOWDT, PR, NOPUT,NOPROTECT
#use delay (clock=20M)

#PIN_SELECT U1TX=PIN_B13
#PIN_SELECT U1RX=PIN_B12
#USE RS232(UART1,ERRORS,BAUD=9600)

#use fast_io(A)
#use fast_io(B)
#define MMC_CLK   PIN_A3
#define MMC_DI    PIN_B4
#define MMC_DO    PIN_A2
#define MMC_CS    PIN_A4



#include "C:\Users\Desktop\SD_CARD\mmcsd.c"
#include "C:\Users\Desktop\SD_CARD\fat.c"


void main(void)
{
   BYTE value, cmd;
   int32 address;
int i;
uint8_t buf[512];
MMCSD_err err;

if (mmcsd_init() == MMCSD_GOODEC)
{
  printf(" initialised successfully, proceed");
}
else
{
   printf("didn't initialise, do something else");
}
 printf("\n");
mmcsd_read_byte(10, 10);
if (mmcsd_read_byte(10, 10) == MMCSD_GOODEC)
{
  printf(" read_bytesuccessfully, proceed");
}
else
{
   printf("didn't read_byte");
}
 printf("\n");

               
.....

}
ckielstra



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

View user's profile Send private message

PostPosted: Fri May 17, 2013 11:57 am     Reply with quote

Quote:
I receive the message didn't initialise, do something else
This doesn't make you happy, but to me now things are starting to make sense again: you have a hardware problem with connecting the SD card.

With a hardware problem present there is no way you will be able to fix the problem in software.

I did a little investigation in the Arduino hardware extension boards and it turns out the Arduino is running 5V. The SD card and your dsPIC are running 3.3V. Now, what I expect is that the extra components you have on your SD card PCB are for the 5V to 3.3V conversion and the other way around. This is making things worse for you. In fact, the board is useless and you'll have to make some serious modifications to make it suitable for your project.
You can try to connect your board supplier and ask for the schematic. Most likely it will involve removing all components from the PCB except the two connectors. Ensure there is at least a pull up resistor (100k) on the MISO line, perhaps on on the clock and CS line as well.
Better, get yourself another interface board.
The schematic should be similar to:
Note that this schematic only has pull-up resistors, not resistor voltage-dividers as you board most likely has for 5V to 3.3V conversion.
Jim90



Joined: 27 Apr 2013
Posts: 55

View user's profile Send private message

SD card memory problem
PostPosted: Fri May 17, 2013 6:23 pm     Reply with quote

Fo you think the values of the resistors are right ?

http://obrazki.elektroda.pl/4648241000_1368836436.png

With these pull- up resistors is anything else which i need to add ?
andrewg



Joined: 17 Aug 2005
Posts: 316
Location: Perth, Western Australia

View user's profile Send private message Visit poster's website

PostPosted: Fri May 17, 2013 9:13 pm     Reply with quote

No. What you're describing as "pull-up resistors" are actually divider resistors, designed to interface a 5V micro (Arduino) with the 3.3V SD card.

To connect your dsPIC33FJ128GP202 to an SD card you don't need divider resistors, you need pull-ups to 3.3V as shown on ckielstra's circuit diagram (the open triangle at the top represents the 3.3V SD/microcontroller power supply).
_________________
Andrew
Jim90



Joined: 27 Apr 2013
Posts: 55

View user's profile Send private message

SD card memory problem
PostPosted: Sat May 18, 2013 5:57 am     Reply with quote

Yes but 50K resistor is not very high ? (i expecting a value of 1-2 K)
andrewg



Joined: 17 Aug 2005
Posts: 316
Location: Perth, Western Australia

View user's profile Send private message Visit poster's website

PostPosted: Sat May 18, 2013 6:33 am     Reply with quote

The idea with pullups is that they are generally intended to put a signal line into a default state when it isn't being driven. A higher resistor value means that when the line *is* driven, it doesn't need a lot of current to get it to change state. Typical pull-up values will be 10K to 100K, although there are exceptions.
_________________
Andrew
Jim90



Joined: 27 Apr 2013
Posts: 55

View user's profile Send private message

SD card memory problem
PostPosted: Tue May 21, 2013 5:06 pm     Reply with quote

I tried 50K without results.

Any ideas ?
ckielstra



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

View user's profile Send private message

PostPosted: Wed May 22, 2013 1:27 am     Reply with quote

Please be more descriptive about your current hardware setup. If possible post a schematic of the connections between the PIC and SD card, otherwise describe each line in a few words like:
- Pin xx of PIC goes to Pin yy of SD, pull up resistor 50K to 3.3V
- etc.
Jim90



Joined: 27 Apr 2013
Posts: 55

View user's profile Send private message

SD card memory problem
PostPosted: Sun May 26, 2013 7:26 pm     Reply with quote

The connections are :
SD card --- dspic
MMC_CS -->PIN_B6
MMC_CLK -->PIN_B10
MMC_DO -->PIN_B11
MMC_DI -->PIN_B7

For each one of the PIN is connect a pull up resistor (50K)

PIN_B6 --> 50K-->3.3V
PIN_B10 --> 50K-->3.3V
PIN_B11 --> 50K-->3.3V
PIN_B7 --> 50K-->3.3V


I did these changes to the code:

Code:

#define MMC_CS    PIN_B6
#define MMC_CLK   PIN_B10
#define MMC_DO    PIN_B11
#define MMC_DI    PIN_B6
ckielstra



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

View user's profile Send private message

PostPosted: Mon May 27, 2013 1:32 am     Reply with quote

Code:
#define MMC_CS    PIN_B6
#define MMC_CLK   PIN_B10
#define MMC_DO    PIN_B11
#define MMC_DI    PIN_B6
PIN_B6 is used two times!!!

You didn't mention the pin number on the SD card connector but it looks like your data connection is 'straight' where it should have been 'crossed': Data IN of SD goes to Data OUT of PIC and vice versa.
So check:
The Data In pin of the SD card (pin 2) should be connected to the Data Out of your PIC (B11)
The Data Out pin of the SD card (pin 7) should be connected to the Data In of your PIC (B7)

I don't have the compiler for the PIC33 series, but most likely you will have to add the code for the remap-able pins just under your pin defines:
Code:
#PIN_SELECT SCK1=PIN_B10
#PIN_SELECT SDO1=PIN_B11
#PIN_SELECT SDI1=PIN_B7
PIN_B6, your CS output, is not in this list as it shouldn't use the CS output from the SPI hardware unit. This pin is to be mapped as a general output port
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2, 3
Page 3 of 3

 
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