Jump to content
43oh

PetiteFS FATfs SDCard USCI code


Recommended Posts

The file size should be fine, I used "fsutil file createnew " under XP. I added some random characters.

 

I might have an error in reasoning. I tryed adding pf_lseek(10) to prevent first 10 bytes(?) to be overwritten:

 

printf("Writing 100 lines of text data\n");
				res = pf_lseek(10);		// Added Code
				do {
					ltoa(++n,Line);
					strcat(Line," The quick brown fox jumps over the lazy dog. 1234567890\r\n");
					res = pf_write(Line, strlen(Line), &bw);

 

Suggesting that my first 10 bytes will stay - but still it all was overwritten by the brown fox.

How do I correctly move the write pointer before writing?

 

After that, next question would be, how correctly save the current pointer value for the next append operation?

 

jh155, what is your circuit like?

Sorry for my limited English - I'm not getting the question. If you are asking about the wiring of the SD-Card: I did it the same way as given above.

 

Thanks for the support!

 

PS: I just checked the elm-chan website for the write comand anf found:

pf_lseek(ofs); read/write pointer must be moved to sector bundary prior to initiate write operation or it will be rounded-down to the sector boundary.

pf_write(buff, btw, &bw); Initiate write operation. Write first data to the file.

If I anderstand that right, I can only move the pointer x times of 512bytes. Otherwise it will be rounded down and overwrites the current sector. I will test this later tonight.

Link to post
Share on other sites
  • Replies 144
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

Edit: July 6th, 2014 Please also note that Pabigot maintains BSP430 which has an example for the msp430. He also tracks any changes done to the ElmChan library with patches made to the example. Refer

I went ahead and tested the booster pack and added the write support in the attached zip file. You should take a look at the Petit FatFS documentation regarding the write limitations. PetiteFS only

I took a look at the software serial code - I'm not seeing any issues with gutting it and using hardware UART unless I'm missing something obvious.  I'm not seeing anything that sets anything affectin

Posted Images

  • 2 months later...

Hi All,

 

the SD-Code works well so far.

 

Now I was about to add an SPI-LCD (DOG-M) to the same SPI-Bus of the SD-Card.

LCD and SD are working well if used seperately - but not at the Same time! SD-Card gets write errors if a file is still openend for wrining.

It seems to me, that the SD-Card remains CS_aktiv and witing for further data if the 512byte block has not been finished. And if the LCD jumps in and get's some Data the SD-Card gets mixed up even if the SD_CS is pulled up (deactiv) during LCD Data transmition.

 

Maybe it might also be necessary to disable the clock at the sd-crad wile LCD is getting data?

 

Has anyone discoverd simular problems while using PetiFat File of Elm Chan and a 2nd SPI-device at the same time?

Thnaks a lot.

 

Cheers,

Johannes

Link to post
Share on other sites
  • 2 weeks later...

I solved the problem by using a tri-state-buffer 74HC125 to cut off the connection of the SD-Card Clock and MOSI. The tri-state-buffer is driven by the SD-Card CS. It works great!

 

Also I generate the Dog-M SPI-LCD CS by a NOT-operation of the SD-CS and I use the MISO Pin for the RS Signal. This gives me 2 more free pins on my LaunchPad-Data-Logger with SD-Card an LCD. :)

 

Thanks for the share!

 

Greetings,

Johannes

Link to post
Share on other sites
  • 4 months later...

found a tiny typo in spi.c : P2DIR |= BIT0; this must be P2DIR &= ~BIT0;

this is the card select signal which is active LOW

...I'm working on some changes to use TIMER1A instead of TIMER0A this will free P1.1 and P1.2 to be used for hardware uart USCIA0, when it's ready I will post it here

Some tips: you can use a 8gb sd card with no problems,the max file length of 1 file = 2^32 - 1 bytes

to write an 4GB empty file(filled with 00h) in a simple way : dd if=/dev/zero of=/home/"your home directory"/write.txt bs=512 count=8388607

then copy the file to the sd card on your pc,now you can log 4gb of data with your launchpad

to read the whole file, put the sd card in your pc again to read it as sending it by 9600baud over the launchpad will take 1200 hours :)

Also there is no need to format a new card as 8gb cards are already fat32

 

Thank you Rick for the great work of figuring out to implement petite FS

Best regards from Saigon

Link to post
Share on other sites

added upgraded softserial which used TIMER1A instead of TIMER0A test pin for serial moved from p1.5 to p1.0 as p1.5 is used for the sd card

modified main.c bigger buffer size from 64 char to 200 char , made the test string much longer and can't oveflow the buffer while writing to the sd card

spi .c .h moved the sd card select to p2.2

write.rar.zip is 4GB file full with zero's you can use it on a 8gb sd card as log file: first unzip it,(becomes 2.5mb then use unrar it becomes a 4gb write.txt file the max file length for a logger :smile:

don't try to use the ft command on this file... :smile: as it will take 1200hr to transmit by the launchpad

 

I must say that i'm surpriced of the capabilities of such a tiny msp430g2553

Many thanks to

TI to bring this launchpad development kit for such a nice price on the market

mr Dang of TIfor all example programs

And mr Rick of this forum for the PFS implementation

 

 

 

Greetings From Saigon,Vietnam

main.c

softserial.c

softserial.h

spi.c

spi.h

write.rar.zip

Link to post
Share on other sites

added upgraded softserial which used TIMER1A instead of TIMER0A test pin for serial moved from p1.5 to p1.0 as p1.5 is used for the sd card

modified main.c bigger buffer size from 64 char to 200 char , made the test string much longer and can't oveflow the buffer while writing to the sd card

spi .c .h moved the sd card select to p2.2

write.rar.zip is 4GB file full with zero's you can use it on a 8gb sd card as log file: first unzip it,(becomes 2.5mb then use unrar it becomes a 4gb write.txt file the max file length for a logger :smile:

don't try to use the ft command on this file... :smile: as it will take 1200hr to transmit by the launchpad

 

I must say that i'm surpriced of the capabilities of such a tiny msp430g2553

Many thanks to

TI to bring this launchpad development kit for such a nice price on the market

mr Dang of TIfor all example programs

And mr Rick of this forum for the PFS implementation

 

 

 

Greetings From Saigon,Vietnam

I updated the first post, with this link. Thanks!

Link to post
Share on other sites
  • 3 weeks later...
  • 1 month later...

I tried to rebuilt the project using IAR but I've got several warning and error:

 

 

main.c  
Warning[Pe188]: enumerated type mixed with another type
Warning[Pe188]: enumerated type mixed with another type
Warning[Pe223]: function "ltoa" declared implicitly
Warning[Pa089]: enumerated type mixed with another enumerated type
Warning[Pa089]: enumerated type mixed with another enumerated type
print.c  
softserial.c  
Warning[Pa082]: undefined behavior: the order of volatile accesses is undefined in this statement
Warning[Pa082]: undefined behavior: the order of volatile accesses is undefined in this statement
spi.c  
Linking
Error[e46]: Undefined external "ltoa" referred in main ( C:\Users\Dreamy Sailor Duy\Documents\My Project\SD card\SDCARD_PetiteFS_g2553\Debug\
Obj\main.r43 )
Error while running Linker
 

I wonder if this project works well with ccs

Link to post
Share on other sites
  • 2 weeks later...

Where is itoa used in the code? Could you pint me to the line number?

					do {
						ltoa(++n,Line);
						strcat(Line," The quick brown fox jumps over the lazy dog. 1234567890\r\n");
						res = pf_write(Line, strlen(Line), &bw);
						if (res != FR_OK) {
							put_rc(res);
							break;
						}
						if ( n & 0x10 ) {
							printf(".");
						}
					} while(n < 100);

in main.c.

Do I have to use these code with CSS? I've only IAR

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...