Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with PIC32-Pinguino-Micro and µSD-Interface
27-03-2012, 04:20 PM,
#1
Problem with PIC32-Pinguino-Micro and µSD-Interface
Hello,
i want to save sensordata on a microSD card but i don't how to do this. the examples in the sd library don't work. I hope someone can give me an examlplesketch that i can understand how to write on the microSD card.

thanks, tim
Reply
28-03-2012, 12:12 AM,
#2
RE: Problem with PIC32-Pinguino-Micro and µSD-Interface
Hi Tim,

it would help people help you if you included the information asked for in "Read this before posting", such as the version of the Pinguino IDE you are using, your computer type (PC/Mac/linux etc) as well as the card.

Also, try reading this thread which may give you somewhere to start:

http://forum.pinguino.cc/showthread.php?tid=3408.
Board = PIC32-Pinguino-OTG Rev C
OS = Linux Unbuntu 11.10 till 26 Apr 2012
OS = Linux Unbuntu 12:04 from 27 Apr 2012
Reply
28-03-2012, 09:52 AM,
#3
RE: Problem with PIC32-Pinguino-Micro and µSD-Interface
Hi mf01,

i use a PC/Notebook with WinXP SP3/Win7 and i've downloaded and install the IDE X.2 rev 305 for Windows on both systems. After installation i tested the examples for sd card like Dir.pde but i got an error by compilation. The thread of your post i have read for some days, downloaded the x.3 revision with SVN and copy the files like it's listed in the thread. Here is the output:

Board: PIC32 Pinguino Micro
Proc: 32MX440F256H
c:\Pinguino32X.2\p32\include\pinguino\libraries/sd/sdmmc.c:239:10: error: 'SDCD' undeclared (first use in this function)
c:\Pinguino32X.2\p32\include\pinguino\libraries/sd/sdmmc.c:251:10: error: 'SDWP' undeclared (first use in this function)
error while linking C:\PinguinoX.2\examples\10.Libraries\SD\Dir.o

Some ideas how to fix my problem?
Reply
28-03-2012, 02:55 PM,
#4
RE: Problem with PIC32-Pinguino-Micro and µSD-Interface
First, select the board in the preferences menu ( PIC32-PINGUINO-OTG instead of PIC32-PINGUINO-MICRO ).

(28-03-2012, 09:52 AM)cyberfreak305 Wrote: Hi mf01,

i use a PC/Notebook with WinXP SP3/Win7 and i've downloaded and install the IDE X.2 rev 305 for Windows on both systems. After installation i tested the examples for sd card like Dir.pde but i got an error by compilation. The thread of your post i have read for some days, downloaded the x.3 revision with SVN and copy the files like it's listed in the thread. Here is the output:

Board: PIC32 Pinguino Micro
Proc: 32MX440F256H
c:\Pinguino32X.2\p32\include\pinguino\libraries/sd/sdmmc.c:239:10: error: 'SDCD' undeclared (first use in this function)
c:\Pinguino32X.2\p32\include\pinguino\libraries/sd/sdmmc.c:251:10: error: 'SDWP' undeclared (first use in this function)
error while linking C:\PinguinoX.2\examples\10.Libraries\SD\Dir.o

Some ideas how to fix my problem?

Reply
28-03-2012, 02:59 PM,
#5
RE: Problem with PIC32-Pinguino-Micro and µSD-Interface
Hi

I can confirm the problem, it appears only if PIC32-PINGUINO-MICRO board is selected.
With PIC32-PINGUINO-OTG the program is compiled without problems.


Bye Bye, Moreno
Reply
28-03-2012, 10:38 PM, (This post was last modified: 28-03-2012, 10:43 PM by mf01.)
#6
RE: Problem with PIC32-Pinguino-Micro and µSD-Interface
Hi,

the problem appears to be in the SDMMC.h file in the SD library - it only knows about the PIC32 PINGUINO) and PIC32 PINGUINO OTG cards ;-).

Lines 28 -35 of that file read :-

Code:
// I/O definitions
#if defined(PIC32_PINGUINO) || defined (PIC32_PINGUINO_OTG)
        //#define READ_LED                      13
        //#define WRITE_LED                     13
        //#define SDWP                             // Write Protect input
        //#define SDCD                                  // Card Detect input
        //#define SDCS                                  8       // D8_MMC_#SS Card Select output
#endif

I suspect a similar section needs to be added for the PIC32_PINGUINO_MICRO. It will need to be a separate section as for the PIC32_PINGUINO_MICRO the Green LED is on Pinguino Pin 32 not 13. Also looking at the Olimex schematic and the digitalw.c file it would appear that RB13 (which is connected to SD CS) is not mapped to a Pinguino Pin Number, so some changes may also be needed to the digitalw.c file.

What I had not realised until researching this reply was that the SD library uses the green LED on a PIC32-Pinguino OTG as a read/write indication. I had been wondering why the green LED appeared to flash at the same time as the yellow led which I was using separately in a program to indicate program activity Huh.
Board = PIC32-Pinguino-OTG Rev C
OS = Linux Unbuntu 11.10 till 26 Apr 2012
OS = Linux Unbuntu 12:04 from 27 Apr 2012
Reply
29-03-2012, 11:25 AM,
#7
RE: Problem with PIC32-Pinguino-Micro and µSD-Interface
Hi,
i edit some of the files like digitalw.c:

#ifdef PIC32_PINGUINO_MICRO

const u32 portmask[]= { pB, pB, pB, pB, pB, pB, pB, pB, // 0-7
pB, pB, pD, pD, pD, pD, pD, pD, // 8-15
pB, pD, pD, pD, pG, pF, pE, pE, // 16-23
pE, pE, pE, pE, pE, pE, pC, pC, // 24-31
pG, // 32
pB, pG, pG, pG }; // 33-36 EDIT***

const u32 pinmask[]= { _1, _2, _3, _4, _8, _9, _10, _11, // 0-7
_12, _14, _1, _2, _3, _4, _5, _6, // 8-15
_0, _7, _8, _11, _9, _1, _7, _6, // 16-23
_5, _4, _3, _2, _1, _0, _13, _14, // 24-31
_6, // 32
_13, _7, _8, _9 }; // 33-36 EDIT***
#endif

and the sdmmc.h:

#if defined(PIC32_PINGUINO_MICRO)
#define READ_LED 10 // Yellow LED
#define WRITE_LED 32 // Green LED
//#define SDWP // Write Protect input
//#define SDCD // Card Detect input
#define SDCS _RB13 // D8_MMC_#SS Card Select output
#endif

and also the fileio.h:
...
// globals
//char SDCS; // EDIT***
char FError; // error mail box
FATFS *Fat; // mounting info for storage device
...

After editing the files, the program Dir.pde get compiled with no errors. Now i have load the .hex at the board. When i open the terminal in ubuntu and open minicom (sudo minicom -o -D /dev/ttyACM0) AND TOUCH WITH MY FINGER AT PIN 1(CON1) (i am confused :-)) i get the output:

Press RETURN to start. //=> after i press return

Mount failed!
Press RETURN to start.

... and so on. I think the pinning or the spi-routines are not right.
I need some help to get the microSD start working.



Reply
29-03-2012, 11:52 AM, (This post was last modified: 29-03-2012, 11:56 AM by Henk van Beek.)
#8
RE: Problem with PIC32-Pinguino-Micro and µSD-Interface
Hi mf01,

Now digitalw.c and SDMMC.h file are adapted.
As an attachment the new pin definitions.

both files are in http://pinguino32.googlecode.com/svn/branches/x.3

Henk

(28-03-2012, 10:38 PM)mf01 Wrote: Hi,

the problem appears to be in the SDMMC.h file in the SD library - it only knows about the PIC32 PINGUINO) and PIC32 PINGUINO OTG cards ;-).

Lines 28 -35 of that file read :-

Code:
// I/O definitions
#if defined(PIC32_PINGUINO) || defined (PIC32_PINGUINO_OTG)
        //#define READ_LED                      13
        //#define WRITE_LED                     13
        //#define SDWP                             // Write Protect input
        //#define SDCD                                  // Card Detect input
        //#define SDCS                                  8       // D8_MMC_#SS Card Select output
#endif

I suspect a similar section needs to be added for the PIC32_PINGUINO_MICRO. It will need to be a separate section as for the PIC32_PINGUINO_MICRO the Green LED is on Pinguino Pin 32 not 13. Also looking at the Olimex schematic and the digitalw.c file it would appear that RB13 (which is connected to SD CS) is not mapped to a Pinguino Pin Number, so some changes may also be needed to the digitalw.c file.

What I had not realised until researching this reply was that the SD library uses the green LED on a PIC32-Pinguino OTG as a read/write indication. I had been wondering why the green LED appeared to flash at the same time as the yellow led which I was using separately in a program to indicate program activity Huh.



Attached Files Thumbnail(s)
   
Reply
29-03-2012, 12:20 PM, (This post was last modified: 29-03-2012, 12:21 PM by moreno.)
#9
RE: Problem with PIC32-Pinguino-Micro and µSD-Interface
Hi

There is a small correction to do in the MICRO layout.

BUT is connected directly to RDO (now P42) but is even connected, trought the jumper BUT_J, on RD4 (P13).
I think is a good idea add these indication on layout.


There is even a double defined PIN P40 and P32.
The correct pin definition is RG6/SCK-LED1 (the green one)


Bye Bye, Moreno
Reply
29-03-2012, 01:09 PM,
#10
RE: Problem with PIC32-Pinguino-Micro and µSD-Interface
Hi Henk van Beek,

can you upload the new pin definitions in digitalw.c again because you have forget a "," in line 115 :-)
This is now correct:

#ifdef PIC32_PINGUINO_MICRO

const u32 portmask[]= { pB, pB, pB, pB, pB, pB, pB, pB, // 0-7
pB, pB, pD, pD, pD, pD, pD, pD, // 8-15
pB, pD, pD, pD, pG, pF, pE, pE, // 16-23
pE, pE, pE, pE, pE, pE, pC, pC, // 24-31
pG, pF, pF, pD, pD, pG, pG, pF, // 32-39
pG, pB }; // 40-41

const u32 pinmask[]= { _1, _2, _3, _4, _8, _9, _10, _11, // 0-7
_12, _14, _1, _2, _3, _4, _5, _6, // 8-15
_0, _7, _8, _11, _9, _1, _7, _6, // 16-23
_5, _4, _3, _2, _1, _0, _13, _14, // 24-31
_6, _4, _5, _9, -10, _8, _7, _0, // 32-39
_6, _13 }; // 40-41
#endif
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)