Jump to content

inspect

Members
  • Content Count

    3
  • Joined

  • Last visited

About inspect

  • Rank
    Noob Class

Contact Methods

  • Website URL
    http://none

Profile Information

  • Location
    none
  1. inspect

    Pfatfs library example write problem

    Actually, i am using old MMC with 64 mb.so, it does not have lock tab. I've also copied T_READ.txt and T_WRITE.txt before running the sketch. But oh!!! I see ,I created new blank T_WRITE.txt with one character in MMC but didn't copy the provided blank T_WRITE.txt in example folder with 2KB size. Above link enlists one of the restriction as "cannot expand file size". so is it due to this restriction that i am able to write only one character? Do we need to first define the size of file to be written?
  2. Hello, I am using example code of energia Pfatfs library named "PFatFsfileTest". This program reads "T_READ.txt" file from sd card properly. But It can't write string "Hello world" 10 times to the file "T_WRITE.txt" into sd card. Instead, it just writes only "H". I am posting the original code of file below: /*----------------------------------------------------------------------*/ /* Petit FatFs sample project for generic uC (C)ChaN, 2010 */ /*----------------------------------------------------------------------*/ /* ported to Energia */ /* copy the two files t_read.txt and t_write.txt from the example folder in the root of the sd card*/ #include "SPI.h" #include "pfatfs.h" #define cs_pin 10 // chip select pin #define read_buffer 128 // size (in bytes) of read buffer unsigned short int bw, br;//, i; char buffer[read_buffer]; int rc; DIR dir; /* Directory object */ FILINFO fno; /* File information object */ void setup() { pinMode(PUSH2, INPUT_PULLUP); Serial.begin(9600); // initialize the serial terminal FatFs.begin(cs_pin); // initialize FatFS library calls } void die ( /* Stop with dying message */ int pff_err /* FatFs return value */ ) { Serial.println();Serial.print("Failed with rc=");Serial.print(pff_err,DEC); for (; ; } /*-----------------------------------------------------------------------*/ /* Program Main */ /*-----------------------------------------------------------------------*/ void loop() { Serial.println(); Serial.println("Press button to start..."); while(digitalRead(PUSH2)==1){} delay(100); while(digitalRead(PUSH2)==0){} Serial.println(); Serial.println("Open a test file (t_read.txt)."); delay(100); rc = FatFs.open("T_READ.TXT"); if (rc) die(rc); Serial.println(); Serial.println("Type the file content."); delay(100); for (; { rc = FatFs.read(buffer, sizeof(buffer), &br); /* Read a chunk of file */ if (rc || !br) break; /* Error or end of file */ for (uint16_t i = 0; i < br; i++) /* Type the data */ Serial.print(buffer[i]); delay(100); } if (rc) die(rc); Serial.println(); Serial.println("Open a file to write (t_write.txt)."); delay(100); rc = FatFs.open("T_WRITE.TXT"); if (rc) die(rc); Serial.println(); Serial.println("Write a text data. (10 x Hello world!)"); delay(100); bw=0; for (uint16_t i=0;i<10;i++) { rc = FatFs.write("Hello world!\r\n", 14, &bw); if (rc || !bw) break; } if (rc) die(rc); rc = FatFs.write(0, 0, &bw); //Finalize write if (rc) die(rc); delay(100); Serial.println(); Serial.println("Verify the write process (t_write.txt)."); delay(100); rc = FatFs.open("T_WRITE.TXT"); if (rc) die(rc); Serial.println(); Serial.println("Type the file content."); delay(100); for (; { rc = FatFs.read(buffer, sizeof(buffer), &br); /* Read a chunk of file */ if (rc || !br) break; /* Error or end of file */ for (uint16_t i = 0; i < br; i++) /* Type the data */ Serial.print(buffer[i]); delay(100); } if (rc) die(rc); Serial.println(); Serial.println("Open root directory."); delay(100); rc = FatFs.opendir(&dir, ""); if (rc) die(rc); Serial.println(); Serial.println("Directory listing..."); delay(100); for (; { rc = FatFs.readdir(&dir, &fno); /* Read a directory item */ if (rc || !fno.fname[0]) break; /* Error or end of dir */ if (fno.fattrib & AM_DIR) {Serial.print("<dir>\t"); Serial.println(fno.fname);delay(100);} else {Serial.print(fno.fsize);Serial.print("\t"); Serial.println(fno.fname);delay(100);} } if (rc) die(rc); Serial.println(); Serial.print("Test completed."); //for (; ; } and i am also posting my terminal output below: Press button to start... Open a test file (t_read.txt). Type the file content. abc Open a file to write (t_write.txt). Write a text data. (10 x Hello world!) Verify the write process (t_write.txt). Type the file content. H Open root directory. Directory listing... 3 T_READ.TXT 3858759679 m 3842012416 N 1409286144 EWTEX~1T.XT Test completed. Press button to start... Plz tell me the solution as soon as possible.
  3. UPDATE: i accidently wrote msp430g2274 instead of msp430f2274 in the title of thread.I tried to change title by editing it using full editor but i can't.It gives me some error that thread key is not matched and it signs out. Hey guys, I first changed boards.txt file under /hardware/msp430 by adding following code lpmsp430fr5739.name=msp430f2274 lpmsp430fr5739.upload.protocol=rf2500 lpmsp430fr5739.upload.maximum_size=32768 lpmsp430fr5739.build.mcu=msp430f2274 lpmsp430fr5739.build.f_cpu=16000000L lpmsp430fr5739.build.core=msp430 lpmsp430fr5739.build.variant=msp430f2274 and also added "pins_energia_.h" which is simply a copy of launchpad's "pins_energia.h" in folder /hardware/msp430/variants/msp430f2274. for now i've not just added pin description of msp430f2274.i am right now just testing whether the code of g2553 can compile or not.when i compile the code it gives me follo\wing error: \energia-0101E0009\hardware\msp430\cores\msp430\twi.c: In function 'twi_init': \energia-0101E0009\hardware\msp430\cores\msp430\twi.c:122:5: error: 'P1SEL2' undeclared (first use in this function) \energia-0101E0009\hardware\msp430\cores\msp430\twi.c:122:5: note: each undeclared identifier is reported only once for each function it appears in But when i change this line in boards.txt: lpmsp430fr5739.build.mcu=msp430f2274 to lpmsp430fr5739.build.mcu=msp430g2553 It successfully compiles.So plz tell me wht m i doing wrong here.?
×