Hello everybody giving a helping hand,
got me some trouble here. I was making a program that reads out the duty cycle of an ADXL202 sensor. Everything works, except the part were i want to print my data in a file using this :
FILE *stream, *fopen(); if ( (stream = fopen(...)) != NULL) fscanf(stream,''%s'', string);
Ok this is were my problems start. The compiler gives me the error that he doesn't know this type FILE ore the function fopen (). This seems to be logical to me since i looked in my stdio.h header and found nothing really according to that declaration. Is there a posibility that this is stored in another source file or does not exist??? Or .... how do i get my data's in a *.txt file ???
Thanks for the help i'm about to receive :))
P.S: Im using a 80C535 µC, sorry for not mantuening
Now would be a good time to stop thinking like a PC programmer and start thinking like an embedded programmer.
Files require an operating system that handles files, or at least a file system driver. Either of those would be an oddity in the uC world
Or .... how do i get my data's in a *.txt file ???
Well, if you tell us where the *.txt file is (on your PCs hard drive ?) and how the uC is connected to it (serial port), maybe we can give you some hints.
My *.txt file is named test_acc.txt and is located on my desktop that means in c:/Dokumente und Einstellungen/Desktop. My controler is via serial port connected to the pc.
My controler is via serial port connected to the pc.
In that case, maybe you should have a look at the putchar(), puts() and printf() functions:
http://www.keil.com/support/man/docs/c51/c51_puts.htm http://www.keil.com/support/man/docs/c51/c51_putchar.htm http://www.keil.com/support/man/docs/c51/c51_printf.htm
They are still very much part of the PC world (and you'll be surprised about the amount of code memory that the "simple" printf functions takes up), but will work on the uC.
Of course, you will have to configure the serial port first and have something (Hyperterminal might do for starters) on the PC side that can receive the output of the uC.
If your uC application has real-time constraints, you may need to "roll your own" serial output routines that are interrupt-driven.
Thanks for the advise but this is not helping me. Maybe im not clear enought. My fault, sorry. I am using HyperTerminal to comunicate with my µC. And i can see the data he's sending me via serial port but on the terminal window. Now if i want to hape this data in a text or in a excel file (even better) i must record the transmision on the terminal. I would like to see the data in my terminal window but at the same time record it in a text file or a tabel in Excel. That would be great because i must deliver a diagram and trough that i could save a step. I mean i still receive data in my terminal, see if there are corect, record tham in txt input them in excel and make my diagramm. Now if i could transfer them directly to the Excel file and make the diagram i could save 1-2 steps and so make a "automatical" program.
"I am using HyperTerminal to comunicate with my µC. And i can see the data he's sending me via serial port but on the terminal window. Now if i want to have this data in a text or in a excel file (even better) i must record the transmision on the terminal."
That's right - this is a PC question, not a Keil question.
Hypoterminal can record the received data to a file - see 'Capture Text' on the 'Transfer' menu.
Or you can write your own PC application to automate the process.
To do it in Excel, see: www.windmill.co.uk/rs232.html
Remember: as far as the PC is concerned, it's all just serial data - the fact that it happens to be coming from an 8051 is entirely irrelevant to the PC.
View all questions in Keil forum