Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pinguino sd issue
13-07-2012, 01:59 AM,
#1
pinguino sd issue
Hi all! I finally get the sd card to work with the Pinguino micro. But to start the program I MUST put my finger on pin 1. Is there any solution for this? Thanks for any help.
Reply
13-07-2012, 04:37 PM,
#2
RE: pinguino sd issue
i FOUND MYSELF THE ANSWER: THE PIN1 AND PIN2 OF CONNECTOR 1 ARE FROM THE RTCLOCK XTAL OSCILATOR. You must put a Xtal or other source of oscilator .
Also in the sdmmc.h file (version of [30-03-12][hgmvanbeek@gmail.com) the definition of the cs pin MUST be changed from:
#define SDCS 41 // RB13/MMC_#SS Card Select output
to:
#define SDCS 40 // RB13/MMC_#SS Card Select output
Reply
13-07-2012, 06:31 PM,
#3
RE: pinguino sd issue
Hi aimore,

just to note the definition of SDCS was changed in X.3 r403 on 10 May 2012.

There were also some other changes made in May 2012 to deal with cards, such as the Micro, which do not either have a RTCC or the components to allow the RTCC to be used.

The latest versions of the various SD library files can be found at http://code.google.com/p/pinguino32/sour...aries%2Fsd.

Regards
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
12-01-2013, 07:52 PM, (This post was last modified: 12-01-2013, 08:18 PM by jumpjack.)
#4
RE: pinguino sd issue
So which value should I use for SDCS_PIN in SD.mount(SDCS_PIN) for a MICRO?

Ok, found in Olimex new example file (in readme.txt) :

(!!) FOR PIC32-PINGUINO-MICRO, in every example you need to use
SD.mount(40) instead of SD.mount(8) (Card Select is on pin 40)
Reply
12-01-2013, 10:17 PM,
#5
RE: pinguino sd issue
Ok, here it is my first attempt of a SD logger sketch working on MICRO boards; currently it does not log anything, it just write TEST to a file. But if you find the file on the SD and it contains the word TEST... well, it's working! :-)

Instructions:
Put SD card inside
Power up board
Red LED lights: you have 3 seconds to connect your favourite serial monitor
After 3 seconds, red led turns off, Green led turns on: program is started!
If all goes as expected, the green led will eventually blink fast.
If instead you see red led on, there was a problem with the SD card.

Code:
/*-----------------------------------------------------
Author:  --<Jumpjack>
Date: 12/Jan/2013
Description: Basic SD logger test - PINGUINO MICRO compatible

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

void setup() {

#define BUFFER_SIZE 32  // Size of read buffer - arbitrary length,
                        // try changing it to improve efficiency

   u16      i, lines_total, bytes_to_write, bytes_written, bytes_read;
   u32      bytes_total;
   u8       filename[]  = "datalog1.csv";       // should include full path to file
  
   FIL      fil;    // File object
   FRESULT  res, rc;
   DWORD    file_size;
   u8       read_buffer[BUFFER_SIZE];
   u8  buffer[40]  = "";    // arbitary value of 40 for length of character array
                              // needs to be large enough for maximum line length
   u8  temp[13]    = "";    // temporary variable used for int to char conversions
                              // needs to be large enough for maximum string length
                              // generated by sprintf() statements below


#if (defined(PIC32_PINGUINO) || defined (PIC32_PINGUINO_OTG))
   #define SDCS_PIN 8      // The pin for the SD Card select line: 8 for OTG, 40 for MICRO
#endif


#ifdef PIC32_PINGUINO_MICRO
    #define SDCS_PIN 40      // The pin for the SD Card select line: 8 for OTG, 40 for MICRO
#endif

//////////////////////////////////
// Header code: use LEDs to communicate with the user that board is on,
// it is waiting for connection, and then is ready.
// Put this code in front of all examples to better debug them.

    pinMode(10, OUTPUT); // Red
    pinMode(32, OUTPUT); // Green
    
    digitalWrite(10,HIGH);  // Red on: waiting for user to connect to serial
    digitalWrite(32,LOW);
    delay(3000);
    digitalWrite(10,LOW); // End wait: ready to start program; Green LED on, Red off.
    digitalWrite(32,HIGH);
    delay(1000); // Just let the Green LED stay on for some time before switching to other program uses.
    
//////////////////////////////////    

    CDC.println("Press ENTER to start");
      //while (CDC.getKey() != '\r');                        // wait for RETURN key to start  (not always working?!?)
    CDC.println("Program started.");

   Sprintf(temp, "Test\n");  // dummy data
   strcat(buffer, temp);    
   bytes_to_write = strlen(buffer);         //  number of Bytes To be Written
  
    SD.mount(40);     //8=pinguino, 40=MICRO

   res = SD.open(&fil, filename, FA_OPEN_ALWAYS | FA_READ | FA_WRITE);
   if (!res){
      file_size = fil.fsize;     // Get existing file size
      SD.seek(&fil,file_size);   // Set R/W pointer to end of file


      rc = SD.write(&fil, buffer, bytes_to_write, &bytes_written);              // write new data to file
      SD.flush(&fil);                                                           // flush any data in cache to file
                                 // to avoid data loss from loss of power etc
                                 // only required if not closing file
      SD.close(&fil);            //     Included for safety to ensure file properly closed
      SD.unmount();              //     in case user removes card instead of proceeding.
                                                                                                                              

      if (bytes_to_write == bytes_written){                                                                     // check that all bytes written to file
         CDC.printf("*** New data added ***\r\n%s", buffer);    // prints out buffer
      }
   }
      else {
         CDC.printf("\n\r*** Not all data written ***\n\r", filename);
         digitalWrite(32,LOW); // Green LED off.
         digitalWrite(10,HIGH); // Error in SD card management: RED led on
         while (1); // Lock up.
      }
    digitalWrite(10,LOW); // Success: ensure Red LED is off.
        }

void loop() {
    // Write successful: green led blinking.
    toggle(32);
    delay(100);
    }
Reply
12-01-2013, 10:25 PM,
#6
RE: pinguino sd issue
Hi

Obviously 40


Bye Bye, Moreno
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)