5 years, 7 months ago.

I wanna get the millisec of the RTC in mbed.

I wanna get the millisecond of the Real Time Clock in mbed.

I made a mbed board; implements a outer sensor and the SD card (connet the SPI / p5-p8).

The clock of the sensor is 100kHz, I want to write RealTimeClock and data value from the sensor to the SD card.

I hope the Data written to SD: ex. 14:43:12.123 data... (Hour:Min:Sec.millisec).

Therefore, I use "strftime(buffer, 32, "%T.%3N\n", localtime(&seconds));", but I didn't get the millisec.

(I understand that the format of %3N is in Ruby, and isn't mbed.)

Please tell me how to use millisec.

1 Answer

5 years, 7 months ago.

IIRC the LPC1768 has no milliseconds counter for its RTC (no target will have one, since the 32.768kHz of a crystal can't be properly divided to 1000kHz, however the Nucleo ones have something which could approximate it).

You could for example use: http://developer.mbed.org/users/Sissors/code/RTC/, and attach a seconds interrupt which resets a timer, and the value of that timer is then used for the milliseconds. However you then do keep issues between RTC and milliseconds synchronization.

Accepted Answer

Dear Mr. Erik,

I thank your kindness for response.

I understand that LPC1768 haven't millisec function of RTC. I made a original PCB, because it has restriction, so I can't the Nucleo board (STM).

I see your RTC lib, I think that it's easy interface of RTC attach. I understand that It's necessary for synchronization between RTC and millisec timer.

Thank you for your replay. Regards, A. Hashimoto.(JPN)

posted by Akinori Hashimoto 30 Mar 2015