how we can create .txt file in embedded c

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shilesh
    New Member
    • Jun 2014
    • 1

    how we can create .txt file in embedded c

    int readADC(int channel)
    {
    int val=0;
    ADCSRA |= (1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0) | (1 << ADIF);; // Set ADC prescalar to 128 - 125KHz sample rate @ 16MHz
    ADMUX = channel;
    ADMUX |= (1 << REFS0); // Set ADC reference to AVCC
    ADMUX |= (1 << ADLAR); // Left adjust ADC result to allow easy 8 bit readin
    //ADCSRA |= (1 << ADFR); // Set ADC to Free-Running 4
    ADCSRA |= (1 << ADEN); // Enable ADC
    ADCSRA |= (1 << ADSC); // Start A2D Conversions
    while(!(ADCSRA & (1<<ADIF)));
    ADCSRA|=(1<<ADI F);
    //val = ADCL+(ADCH<<8);
    val=ADC;
    return val;
    }
    int main()
    {
    FILE *f1;
    char ch;
    //writing char to file
    //error=> f1=fopen("ADC11 .txt","w");
    while((ch=getch ar())!=EOF)
    putc(ch,f1);
    fclose(f1);
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Did you #include <stdio.h> ?

    Comment

    • aleciagibbons14
      New Member
      • Jun 2014
      • 18

      #3
      i just research the answer i did not find yet,, hope their are someone know so that we also knows..

      Comment

      • donbock
        Recognized Expert Top Contributor
        • Mar 2008
        • 2427

        #4
        You say "embedded C"; and the name of that first function is readADC(). Are you coding for an embedded system? It is not uncommon for embedded systems to not support file I/O. What do you know about the system capabilities?

        Comment

        Working...