2015-12-13 09:14 AM
Hi everyone,
I wanna write my variable to USB every second but I can't.I think it can be in while loop f_mount(0, &fatfs); if(f_open(&file, ''0:OLCUM.CSV'',FA_CREATE_ALWAYS | FA_WRITE) == FR_OK) { sprintf (king, '' %d\n '', saniye1); bytesToWrite = sizeof(king); f_lseek(&file, file.fsize); // Seek to tail res= f_write (&file, king, bytesToWrite, (void *)&bytesWritten); f_sync(&file); f_close(&file); f_mount(0, NULL); or in while loop; USBH_Process(&USB_OTG_Core, &USB_Host); but I couldnt..What can I do??but
I could not.
but
I could not.
but
I could not.
2015-12-13 10:54 AM
Ok, so have your SysTick interrupt increment a 1ms tick counter, and then wait for it to advance 1000 ticks?
unsigned int Last = SystemTick; while(1) { unsigned int Current = SystemTick; // .. if ((Current - Last) >= 1000) { Last = Current; Do1HzStuff(); } // .. }2015-12-14 01:17 AM
yes clive,
I have systick and I can control relay every second and at the same time, I wanna write usb every second for my variable such as adc value.which commands should I use?I have usb library such as atollic examples 10CCan I write in a while loop?By the way, I've already written once. I wanna every second for adc valuebut
I could not.
but
I could not.
but
I could not.
2015-12-14 06:29 AM
I don't use Atollic...
Wait for 1s to pass in the idle/core loopvolatile unsigned int systemTick = 0; // Incremented in 1ms SysTick
// ..
f_mount(0, &fatfs);
f_open(&file, ''0:OLCUM.CSV'',FA_CREATE_ALWAYS | FA_WRITE)
// ..
unsigned int Last = SystemTick;
// ..
while(1)
{
unsigned int Current = SystemTick;
// ..
if ((Current - Last) >= 1000)
{
Last = Current; // Or Last += 1000;
res= f_write (&file, sizeof(king), bytesToWrite, (void *)&bytesWritten);
f_sync(&file); // doing this each time is inefficient
}
// ..
}
2015-12-29 07:22 AM
hi clive,
I can write USB but I have some problem again,and I have new topic,https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=%2fpublic%2fSTe2ecommunities%2fmcu%2fLists%2fcortex_mx_stm32%2fUSB%20MSC%20write%20problem&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&TopicsView=https%3A%2F%2Fmy%2Est...