Forum Menu




 


Log in Problems?
New User? Sign Up!
AVR Freaks Forum Index

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
js
PostPosted: Jan 02, 2011 - 11:35 PM
10k+ Postman


Joined: Mar 28, 2001
Posts: 20387
Location: Sydney, Australia (Gum trees, Koalas and Kangaroos, No Edelweiss)

A few links that may help you.

http://www.avrfreaks.net/index.php?name ... 256#770256
http://www.avrfreaks.net/index.php?name ... 731#770731
http://www.avrfreaks.net/index.php?name ... 171#771171
http://www.avrfreaks.net/index.php?name ... 591#774591
http://www.avrfreaks.net/index.php?name ... 921#774921
http://www.avrfreaks.net/index.php?name ... 155#775155

_________________
John Samperi
Ampertronics Pty. Ltd.
www.ampertronics.com.au
* Electronic Design * Custom Products * Contract Assembly
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
Modeon
PostPosted: Jan 03, 2011 - 02:38 PM
Newbie


Joined: Nov 28, 2010
Posts: 7


Thank you a lot, that's what I needed
 
 View user's profile Send private message  
Reply with quote Back to top
clawson
PostPosted: Jan 03, 2011 - 09:10 PM
10k+ Postman


Joined: Jul 18, 2005
Posts: 62349
Location: (using avr-gcc in) Finchingfield, Essex, England

As I think I told you via PM. John Samperi and I have modified the PetitFs code to work on Megas that don't have USI but that do have real UARTs and SPIs. Search out the threads and download the code.

BTW this is not an appropriate thread to continue the diagnose of your PetitFs porting problems - take it to "AVR Forum".

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
san_juan_dad
PostPosted: Jan 17, 2011 - 05:31 PM
Rookie


Joined: Mar 13, 2003
Posts: 36
Location: San Juan Capistrano, CA, USA

Many thanks to everyone that has contributed to this TUT.
I now have FatFS running on a 644p and can:
1) Initialize the disk
2) List directories
3) Open and close a file, with a valid time stamp
But, writing to a file seems to have me stumped. I assume the following process is about right, so correct me please:
a) Open a file for write
b) Write to the “buff” until you have 512, or more bytes
c) Write the first 512 to a sector, using “disk_write”
d) When done, flush the buffer
e) Close the file
My hang-up is that the disk_write function wants to know the “sector”. That’s where I’m stuck. Can anyone help me across this knowledge gap?

Tom
 
 View user's profile Send private message  
Reply with quote Back to top
kubark42
PostPosted: Jan 17, 2011 - 05:41 PM
Hangaround


Joined: Jun 04, 2008
Posts: 254


The sector it's asking for is the memory location of the 512-byte page that you want to write. I haven't used FatFS since I wrote the tutorial, and subsequently rewrote many of the functions to minimize the size and maximize write performance for a very specific task, so I no longer recall exactly how with FatFS you get the sector location after you open the file.

However, I'm certain it will be instantly obvious if you spend a couple minutes looking in the right places. Try backtracking using the example code to see where it gets the sector from.

In any case, this is important, as if you write to the beginning of the file, you're overwriting it, whereas if you're writing to the end you're appending to it. I'm certain you can appreciate the nuance!
 
 View user's profile Send private message  
Reply with quote Back to top
jofre
PostPosted: Jun 24, 2011 - 05:13 PM
Newbie


Joined: Jul 23, 2008
Posts: 18
Location: Houston, TX , USA

I successfully followed this tutorial in April 2009 using same ucontroller as the OP, I did have just some issues with pull ups, but not a big deal as I posted.

Now, based on that the code reported for other members seemed to be just below 32 K . I've attemped to get the FaTFs with an ATMEGA328.

I've downloaded the latest version from elm-chang R08b April 2011 and found out same name changes that clash with the tutorial posted at the beginning of the thread.

For example the chk_power() function in old version is now called power_status(). I am not sure if there are other things.

The problem is that after it compiled with zero errors this is the result:


Code:

AVR Memory Usage
----------------
Device: atmega328p

Program:   47490 bytes (144.9% Full)
(.text + .data + .bootloader)

Data:       2467 bytes (120.5% Full)
(.data + .bss + .noinit)


I've attempted to use the _FS_MINIMIZE parameter but it seems to be there is a bug on the automatization directives as plenty of errors shows up from the calling of the functions supposed to be suppressed in case of using 1,2 or 3, so it only compiles OK with this parameter set to ZERO. I attempted to remove the terminal functions related , but errors still come from other terminal functions not supposed to be suppressed...

So, my question is if anyone know whether this last version may have more functions or what I am doing wrong?

I have attached the complete project. It has the modified rtc.c , however it uses the original uart.c and uart.h from Chang.

Based on the answers if this is not possible to run on an ATMEGA328, then I will look around your modified Petit_FS
posted before as well as the Roland Riegel that is for an ATMEGA168.

Last but not least, the application I am aiming to is to play WAV files from SD card using the PWM. So I just need to read . However,as a side effect I wanted to see if I could fit the whole nine yards on the 328.

Thanks in advance for any advice.

Jose
 
 View user's profile Send private message  
Reply with quote Back to top
jofre
PostPosted: Jun 25, 2011 - 04:55 AM
Newbie


Joined: Jul 23, 2008
Posts: 18
Location: Houston, TX , USA

I've successfully run the Petit FS from Cliff / JS on the Atmega328

Code:


Device: atmega328p

Program:    8810 bytes (26.9% Full)
(.text + .data + .bootloader)

Data:        139 bytes (6.8% Full)
(.data + .bss + .noinit)


Biiiig difference. Not even a 328 is needed.

Please disregard previous crazy post. The only modifications done on the code posted was on the SPI pins as the TX RX on the m164 are the same as on m/168/328.

I like the UART implementation in asm. The only question I have for this post is about the comment from JS

Code:

//The comms is duplex,38.4kbps, but there is no echo and local
// echo needs to be enabled on the terminal.



What does this mean ? no echo as well as "local echo" ?

Thanks a million in advance,

Jose v.
 
 View user's profile Send private message  
Reply with quote Back to top
js
PostPosted: Jun 25, 2011 - 08:34 AM
10k+ Postman


Joined: Mar 28, 2001
Posts: 20387
Location: Sydney, Australia (Gum trees, Koalas and Kangaroos, No Edelweiss)

In the terminal mode you will not see what you are typing unless you enable echo mode in your terminal progam. If you are using Hyperterminal

_________________
John Samperi
Ampertronics Pty. Ltd.
www.ampertronics.com.au
* Electronic Design * Custom Products * Contract Assembly
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
jofre
PostPosted: Jun 25, 2011 - 07:00 PM
Newbie


Joined: Jul 23, 2008
Posts: 18
Location: Houston, TX , USA

Js,
Thanks, I used Bray's terminal and it has a separated tx rx input display.

But, forgive my ignorance on this, how a Hyperterminal feature is related to the USART firmware?

Does this means that the atmega built-in USART automatically echoes on TX what is coming on RX ?and that was no available in Chang's implementation ?

I was playing with single line USART some time ago and I disabled RX when transmitting to avoid self receiving , but I did not verified the opposite.

Thanks for any input. Regards,

Jose v.
 
 View user's profile Send private message  
Reply with quote Back to top
js
PostPosted: Jun 25, 2011 - 11:10 PM
10k+ Postman


Joined: Mar 28, 2001
Posts: 20387
Location: Sydney, Australia (Gum trees, Koalas and Kangaroos, No Edelweiss)

What happened when you typed the message above? Did you see what you were typing?

If you type a line into petitfs you would NOT see anything on a terminal that has a single screen instead of a split send and receive screen, well pretty much like the screen you are reading now. This is the reason for local echo.

Local echo will let you see what you type so that, if you make a mistake and you see it you can edit the line.

I don't remember ever having used a split display terminal program, I always use character echo in my programs that needs input ie the USART receives a char from the keyboard, puts it into a buffer and then sends it back to the terminal.

In rare cases where this doesn't happen in a program (not written by me) I use local echo.

Do you have the ability to have a single screen with Brays instead of 2? If so use it and you will see what I mean.

This is as conprehensive an explanation as I can provide. Smile

_________________
John Samperi
Ampertronics Pty. Ltd.
www.ampertronics.com.au
* Electronic Design * Custom Products * Contract Assembly
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
jofre
PostPosted: Jun 26, 2011 - 06:49 AM
Newbie


Joined: Jul 23, 2008
Posts: 18
Location: Houston, TX , USA

John,

Thanks a lot I have the correct picture now as I also write the USART routines like in Petit that do the same thing just plain send and plain receive but I always use Bray's terminal ( attached) because you can send and receive in Hexadecimal and you can make some macros that are convenient.
[url]
http://hw-server.com/software/termv19b.html
[/url]
This is why I've got in trouble most of the time with the Hyperterminal. Embarassed

Thanks again,

Jose v.]
 
 View user's profile Send private message  
Reply with quote Back to top
osaka
PostPosted: Jul 22, 2011 - 08:07 AM
Wannabe


Joined: Mar 15, 2007
Posts: 74
Location: Spain/Ermua

if someone can share with me any code that can be used with an atmega32 I will be very happy after losing already a week(24 hour a day) trying to have something working on a sd card.

I have read the tutorials, this thread also. I see how the people has succed but I am UNABLE. I started with an atmega16 and changed to atmega32 thinking that atmega16 was insufficient. now I see the code is still to big.

also it seems that the files that were used for this tutorial already changed.


I got this with the elmchan full module. how the... people is getting 10kb codes...

Code:
AVR Memory Usage
      ----------------
      Device: atmega32
      Program:   56266 bytes (171.7% Full)
      (.text + .data + .bootloader)
      Data:       2835 bytes (138.4% Full)
      (.data + .bss + .noinit)



thankyou.
 
 View user's profile Send private message  
Reply with quote Back to top
js
PostPosted: Jul 22, 2011 - 08:30 AM
10k+ Postman


Joined: Mar 28, 2001
Posts: 20387
Location: Sydney, Australia (Gum trees, Koalas and Kangaroos, No Edelweiss)

Quote:
how the... people is getting 10kb codes...
Most likely by using PetitFs (just over 8K) rather than the full FatFs (at least 48K)

_________________
John Samperi
Ampertronics Pty. Ltd.
www.ampertronics.com.au
* Electronic Design * Custom Products * Contract Assembly
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
osaka
PostPosted: Jul 22, 2011 - 10:22 AM
Wannabe


Joined: Mar 15, 2007
Posts: 74
Location: Spain/Ermua

I try to do with the petitfs code but there is always something missing that make me include files from the full module... and I end up will errors and more errors. may be the full version code is ready to run but this small one...I compile the file and I get thousand of errors. If someone has succed with a code smaller than 32kb please share it with me. I am suffering.Sad

what I am doing wrong??
 
 View user's profile Send private message  
Reply with quote Back to top
clawson
PostPosted: Jul 22, 2011 - 10:33 AM
10k+ Postman


Joined: Jul 18, 2005
Posts: 62349
Location: (using avr-gcc in) Finchingfield, Essex, England

Quote:

but there is always something missing that make me include files from the full module..

Tell us more about "something missing"?!?

For me pfsample\avr builds right after download:
Code:
E:\pfsample\avr[i386_vc]>make
avr-gcc -gdwarf-2 -Wall -Os -mcall-prologues -mmcu=attiny85 -DF_CPU=8000000   -c -o main.o main.c
avr-gcc -gdwarf-2 -Wall -Os -mcall-prologues -mmcu=attiny85 -DF_CPU=8000000   -c -o pff.o pff.c
avr-gcc -gdwarf-2 -Wall -Os -mcall-prologues -mmcu=attiny85 -DF_CPU=8000000   -c -o mmc.o mmc.c
avr-gcc -c -mmcu=attiny85 -I. -x assembler-with-cpp -Wa,-adhlns=suart.lst,-gstabs -DF_CPU=8000000 suart.S -o suart.o
avr-gcc -c -mmcu=attiny85 -I. -x assembler-with-cpp -Wa,-adhlns=xitoa.lst,-gstabs -DF_CPU=8000000 xitoa.S -o xitoa.o
avr-gcc -c -mmcu=attiny85 -I. -x assembler-with-cpp -Wa,-adhlns=usi.lst,-gstabs -DF_CPU=8000000 usi.S -o usi.o
avr-gcc -gdwarf-2 -Wall -Os -mcall-prologues -mmcu=attiny85 -DF_CPU=8000000 -Wl,-Map,pfftest.map -o pfftest.elf main.o p
ff.o mmc.o suart.o xitoa.o usi.o
avr-objdump -h -S pfftest.elf > pfftest.lst
avr-objcopy -j .text -j .data -O ihex pfftest.elf pfftest.hex
avr-size -C --mcu=attiny85 pfftest.elf
AVR Memory Usage
----------------
Device: attiny85

Program:    8066 bytes (98.5% Full)
(.text + .data + .bootloader)

Data:        139 bytes (27.1% Full)
(.data + .bss + .noinit)

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
davef
PostPosted: Jul 22, 2011 - 10:34 AM
Resident


Joined: Sep 03, 2005
Posts: 795
Location: Christchurch, NZ

Post the first error that you see.
 
 View user's profile Send private message  
Reply with quote Back to top
osaka
PostPosted: Jul 22, 2011 - 12:34 PM
Wannabe


Joined: Mar 15, 2007
Posts: 74
Location: Spain/Ermua

I downloaded the petit module examples file. I choise AVR folder and I try to compile it.I know I can get some error regarding with the pinout but...

134 errors

undefined reference to 'xmit'
'xfunc_out'
'xputs'
'crvr'
'xmit_spi'.....
 
 View user's profile Send private message  
Reply with quote Back to top
clawson
PostPosted: Jul 22, 2011 - 01:33 PM
10k+ Postman


Joined: Jul 18, 2005
Posts: 62349
Location: (using avr-gcc in) Finchingfield, Essex, England

What were you compiling it with? I have WinAVR20100110 installed which is what runs when I typed "make" above.

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
osaka
PostPosted: Jul 22, 2011 - 02:46 PM
Wannabe


Joined: Mar 15, 2007
Posts: 74
Location: Spain/Ermua

I am using avrstudio5. I have done all kind of small projects with this software. All successfull till this.
BTW, I am a bit confused with the make file. Do I need to handle son makefile? I didn't in the previous projects.
 
 View user's profile Send private message  
Reply with quote Back to top
clawson
PostPosted: Jul 22, 2011 - 02:56 PM
10k+ Postman


Joined: Jul 18, 2005
Posts: 62349
Location: (using avr-gcc in) Finchingfield, Essex, England

Quote:

I am using avrstudio5.

The you kind of deserve everything that you get Wink

Obviously if you DO want to use AS5 and don't want to use it's option to "use external makefile" (I assume it has one like AS4?) then at least start by adding all the .c files from the pfsample/avr to a project set to build for tiny85 and see what errors remain. Once you can get it working for the tiny85 it's designed to build for THEN consider what needs to be done to port it to some other model of AVR.

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2006 The PNphpBB Group
Credits