Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > PSoC® 3 > CREATE A FILE

Bookmark and Share
Cypress Developer CommunityTM
Forums | Videos | Blogs | Training | Rewards Program | Community Components



CREATE A FILE
Moderator:
RKRM

Post Reply
Follow this topic



CREATE A FILE

mmoron21 posted on 01 Oct 2010 8:25 AM PST
Top Contributor
71 Forum Posts

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




Re: CREATE A FILE

bjbu posted on 03 Oct 2010 10:51 AM PST
Cypress Employee
17 Forum Posts

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






ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Spec No: None; Sunset Owner: KXP; Secondary Owner: VWA; Sunset Date: 01/01/20