fprintf not completing

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

fprintf not completing

1,444 Views
bapoo1
Contributor I

Hi all, 

I have been trying to simply write some data to a file using the semihost and corresponding redlib libraries. Below is the code I am using - I can create the file in the correct directory, however, it just stalls when it gets to fprintf. I've read a few posts here saying that the issue is normally not using the semihost-compatible C libraries, but I've made this fix and cannot get the fprintf function to work. Can someone please help? 

//

FILE *fp = fopen("C:\\Users\\BApoo\\Desktop\\Test.txt","w");

if(fp == NULL)
{
printf("Error opening file!\n");
exit(1);
}

const char *text = "This is a string which is written to a file.";

fprintf(fp, "%s\n", text);
fflush(fp);
fclose(fp);

//

0 Kudos
Reply
2 Replies

1,437 Views
converse
Senior Contributor V

Works here.

Which MCU are you using and which debug probe?

0 Kudos
Reply

1,429 Views
bapoo1
Contributor I

Thank you for your prompt response.

I am using the QN9080SIP with a SEGGER J-link probe. If it is of any use, I am using a Keil ULINK 2 Debug Adapter to talk with the MCU over SWD. 

0 Kudos
Reply