0

I'm using a custom board for charging and testing batteries. Its 'brain' is an STM32F407VGT6 microcontroller. I'm developing in Ubuntu (14.04.2 LTS), using ChibiStudio (ChibiOS/RT 3.0 development branch and Eclipse Kepler). While in charge mode, I need to see how much time has passed since I initially started charging the battery. I'm having trouble with writing the necessary steps required for the time measurement. The microcontroller has an internal real-time clock (RTC). It also has timers. And ChibiOS has a time measurement function. However, I went through the documentation, researched online, but I still cannot make it work.

Roh
  • 4,598
  • 6
  • 41
  • 86

1 Answers1

1

First of all, I added two header files inside main.c:

#include "chrtclib.h"
#include "rtc.h"

Secondly, in the makefile of the project, immediately after these 2 lines,

# C sources that can be compiled in ARM or THUMB mode depending on the global setting.
CSRC = $(PORTSRC) \

I added this:

$(CHIBIOS)/os/various/chrtclib.c \

And, finally, I used two functions (from the ChibiOS RTC time conversion utilities) where I needed them inside main.c: rtcGetTimeUnixSec(&RTCD1) and rtcSetTimeUnixSec(&RTCD1, unix_time)