txt FILE on atmega32

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I want to create a small .txt file (of 250 byte)  on atmega32 (i am using avr studio and winavr) contain some data and perform operation of reading and writing and  send it to serial port. fopen and fclose function are not supported on winavr. so please tell how can this done and how to send it from UART.

 

Thank's

 

This topic has a solution.
Last Edited: Sat. May 19, 2018 - 04:13 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Why do you want it to be a file, specifically?

 

But, if you do really want a file, then you will need a file system to manage it.

 

The file system most widely used in these parts is FatFs: http://elm-chan.org/fsw/ff/00index_e.html

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I want to read  one adc channel  and send its data on uart port but as .txt file.  

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Then just send the data as ASCII characters with carriage returns to indicate each end of line and spaces or commas between the data values.

 

At the receiving end, those characters have to be assembled into string(s) and saved as text. 

 

That is the way most folks do it. 

 

There is no such construct as a "file" without a file system. Your UART knows nothing about file systems. And, even if you have a file system with a text file, you still have to send it character by character through the UART and reconstruct it at the other end.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

Last Edited: Fri. May 18, 2018 - 06:06 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just to be clear. You use "capture to file" in your PC terminal program and it will create the file as the AVR sends data.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Correct. In that case, the conversion from a string of characters to a text file is done by the terminal program. It is, however, a step that has to be consciously done. I think the OP was hoping for some way to just send the data and have it appear automatically, as a file, on the other machine.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

On the AVR end, use the uart to send the strings in the pattern you desire, at that point it is just messages going out.

On the PC side, you could use Visual Studio (even the free version) to easily write an app to capture the serial stream & save it into an actual windows text file, excel spreadsheet, or whatever you like.

You could also include a timing function in the PC program to occasionally write a new file of the latest data, to form a logger.

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you format your data into CSV Comma Separated Values, it is easy to capture into a file (at the PC) and import the data into a spread sheet.

See: https://en.wikipedia.org/wiki/Co...

 

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...