Other Parts Discussed in Thread: MSP-FET
Tool/software: Code Composer Studio
Hello,
I am using the msp430f6638 and I am collecting some data from the ADC. I would like to write these data in a text file. So I have written the code to create a file and to open it. When I execute the program it does create the text file but once I stop the program the text file remains empty, the values that I want to write in it are not written in this text file. Here is the code :
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
FILE* fichier = NULL;
fichier = fopen("ADC_TEST.txt", "w");
while (1)
{
if (write_mem==1)
{
write_mem=0;
ADC_value = converted_value;
tab[i]=ADC_value;
i++;
}
if (fichier != NULL)
{
fprintf(fichier,"%d\n",ADC_value);
}
else
{
printf("error");
}
}
fclose(fichier);
}
#pragma vector = ADC12_VECTOR
__interrupt void ADC12_ISR(void)
{
converted_value = ADC12MEM0 & 0x0FFF; // in order to keep only the low 12 bits
ADC12IFG &=~ADC12IFG0;
write_mem = 1;
}
As you can see it's a really simple code and despite that I can't fill in the text file. With this code I am able to create the file but not to write it and I don't know why. The code to create the file is the same I have used before for another project with another MCU and it worked very well. So I am wondering if it's because of the mcu or CCSstudio or maybe a code error, I really don't know how to resolve that. Any help would be appreciated.
Thank you,
Best regards,
Mike