- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I want to create a file into main.c to save some SIgDeltaADC values.
I wrote the typical C code to create a file but this compiler seems not to identify
the pointer.
I get and error in the instruction:
FILE *p;
The compiler sais: undefined identifier.
The code is:
<device.h> <math.h> <stdio.h> main()int result,i;/* Place your initialization/startup code here (e.g. MyInst_Start()) */ /* CYGlobalIntEnable; */ /* Uncomment this line to enable global interrupts. */ "primeros.dat", "wb");for(i=0;i<10;i++)sizeof(int), 1, fp);/*for*/ /*main*/
Some idea to create a file?
#include
#include
void
{
FILE *fp;
ADCDelSig_Start();
fp = fopen(
{
ADCDelSig_StartConvert();
ADCDelSig_IsEndConversion(ADCDelSig_WAIT_FOR_RESULT );
result=ADCDelSig_GetResult8();
fwrite(&result,
}
fclose(fp);
}
/* [] END OF FILE */
#include
- Labels:
-
PSoC 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There isn't a file system on the PSoC 3 system that you are using, so the whole concept of File IO is not defined. Since you are interested in writing to a file, the most likely alternative is to use a communication interface to send data out of the device. The simpliest is likely the UART.
So if you put a UART into your design, then you can write to that UART and have a PC or other device recieve the data.
If you want standard C formatting routines, those are supported by the Keil compiler. For example you can use the sprintf function to create a string and then use the UART_PutString() function to send that string on the UART interface. Make sure to include the stdio.h header file as well:
#include<stdio.h>
You can refer to the help documentation for the Keil compiler (from Creator Help->Documentation->Keil). From there search on stdio. You will find that Keil also has the concept of printf, but that is implementation dependent and needs an interface to use. For PSoC 3 you should use sprintf and then pass that string to whatever commnunications interface that you would like to use.
Brad Budlong
PSoC Sensei