Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

XMC™ Forum Discussions

Not applicable
Hello,

I would like to build a program to write in a SSD card file every second. The main program is an expansion of the WEBSERVER001_Example2.

First I have used the functions of SYSTM001 app to create a timer to call a function every second and to start it. I have done this without any trouble with the next code.

handle_t TimerId;

/*Call update_value() every 1s*/
TimerId = SYSTM001_CreateTimer(1000, SYSTM001_PERIODIC, update_value, NULL);

while(1);
}
SYSTM001_StartTimer(TimerId);
}



The problem is when I call the file_test (Create file and write) function of SLTHA001_Example1 to create and write on a SSD card. At the moment that I call this function, the interrupt stops working. The code is the next.

/* Create file and write */
int file_test(void)
{
FILE *ptr;
status_t status;
const char *filename = "eu.ssi";
uint32_t block_size;
uint32_t num_blocks;

ptr = fopen(filename, "w+");
fseek(ptr, 0, SEEK_SET);

if (ptr == NULL)
return -1;

block_size = sizeof(buffer);
num_blocks = sizeof(char);
fwrite(&buffer, num_blocks, block_size, ptr);
fflush(ptr);

status = fclose(ptr);
CHECK_STATUS(status, -1);

return 1;
}


Could anyone tell me if this is the best way to do it? Why the interrupt stops working? There is another method to perform an interrupt?

Regards and thanks in advance,
MagicPhoton
0 Likes
3 Replies
User6412
Level 4
Level 4
Can you explain this:

while(1);
}
SYSTM001_StartTimer(TimerId);
}

How many times per second you start the timer?
0 Likes
Travis
Employee
Employee
First like received
Hi, Please allow me to look into this issue. 😄
0 Likes
Not applicable
Hello,

Thanks for try to help me. Sorry for my wrong code example, I tried to adapt this code to show my problem but I put the timer timer start in a while(1) loop.

I have solved the problem. The thing was that I used the functions to write in the SD card inside the interrupt vector and this functions were producing another interrupt and the program got hanged.

Best regards,
MagicPhoton
0 Likes