Timer click is a mikroBUS™ add-on board with Maxim’s DS1682 total elapsed time recorder. The main feature of the IC is its elapsed time counter (ETC) used in conjunction with the ALARM pin. Whenever the EVENT pin is held high, the ETC will track time in quarter second resolution. Once the EVENT pin is set to logic low, the time data will be written in the IC’s non volatile EEPROM. The next time the EVENT pin is pulled high, the timer will pick up where it left and continue measuring accumulated time. The upper limit is 34 years. In practical applications, the ALARM pin will be utilized to set off a flag once a certain threshold of accumulated time is reached. The alarm flag is one time programmable. The board communicates with the target MCU through the mikroBUS™ I2C interface, with two additional pins: ALARM (in place of default INT) and EVENT (in place of RST). Designed to use either a 3.3V or a 5V power supply only.
Type | RTC |
Applications | Warranty tracking or other systems where time-of-use is of importance |
On-board modules | Maxim’s DS1682 |
Key Features | 32-bit nonvolatile elapsed time counter, I2C interface with additional pins for alarms and events |
Key Benefits | Records total elapsed time without backup power supply, Resilient against high temperatures and vibration |
Interface | GPIO,I2C |
Input Voltage | 3.3V or 5V |
Compatibility | mikroBUS |
Click board size | S (28.6 x 25.4 mm) |
Here’s a description of individual pins from the DS1682 IC, taken from the official data sheet. Each of these is accessible through the mikroBUS™ pin
EVENT Event Input. The EVENT pin is the input the DS1682 monitors to determine when an event occurs. When the pin is pulled high, the contents of the EEPROM are transferred to the ETC and the oscillator starts. The ETC begins to count in quarter-second increments. When the EVENT pin falls to logic 0, the event counter increments, and the event counter, ETC, and user-memory data are stored in the EEPROM array. When the EVENT pin changes states, the 2-wire bus is unavailable for communications for tEW (falling) and tER (rising). The EVENT input is also deglitched (tG) to prevent short noise spikes from triggering an event.
ALARM Active-Low Alarm Output. The DS1682 monitors the values in the ETC for the programmed value in the alarm register. When the ETC matches the alarm value, the alarm flag (AF) is set. Once set, the alarm flag cannot be reset. See the operating descriptions for the AOS and AP bits for details about the operation of the ALARM pin.
SCL 2-Wire Serial-Clock Input. The SCL pin is the serial-clock input for the 2-wire synchronous communications channel. The SCL pin is an input that requires an external pullup resistor.
SDA 2-Wire Input/Output. The SDA pin is the data input/output signal for the 2-wire synchronous communications channel. The SDA pin is an open-drain I/O, which requires an external pullup resistor.
N.C. No Connection. These pins are not connected internally.
Vcc +2.5V to +5.5V Input Supply
To switch between 3.3V and 5V power supplies, use the onboard jumper.
Code snippet demonstrates how the Timer click counts the elapsed time, as well as the number of events on the EVT pin
1 //TIMER click on socket 1 2 3 #include "timer_hw.h" 4 5 //#define CountFromZero 6 7 // TFT module connections 8 unsigned int TFT_DataPort at GPIOE_ODR; 9 sbit TFT_RST at GPIOE_ODR.B8; 10 sbit TFT_RS at GPIOE_ODR.B12; 11 sbit TFT_CS at GPIOE_ODR.B15; 12 sbit TFT_RD at GPIOE_ODR.B10; 13 sbit TFT_WR at GPIOE_ODR.B11; 14 sbit TFT_BLED at GPIOE_ODR.B9; 15 // End TFT module connections 16 17 sbit TIMER_EVT at GPIOD_ODR.B1; 18 sbit TIMER_ALM at GPIOC_IDR.B1; 19 20 char text[24]; 21 unsigned long ETC; //elapsed time counter 22 unsigned int EC; 23 24 void Display_Init(){ 25 TFT_Init_ILI9341_8bit(320, 240); 26 TFT_BLED = 1; 27 TFT_Set_Pen(CL_AQUA, 1); 28 TFT_Fill_Screen(CL_AQUA); 29 TFT_Set_Font(TFT_defaultFont, CL_BLACK, FO_HORIZONTAL); 30 TFT_Set_Pen(CL_AQUA, 1); 31 32 TFT_Set_Brush(1, CL_AQUA, 0, LEFT_TO_RIGHT, CL_AQUA, CL_AQUA); 33 34 TFT_Write_Text("Event count: ",10,10); 35 TFT_Write_Text("Time count: ",10,50); 36 } 37 38 void MCU_Init() { 39 GPIO_Digital_Output(&GPIOD_BASE, _GPIO_PINMASK_1); 40 GPIO_Digital_Input(&GPIOC_BASE, _GPIO_PINMASK_1); 41 TIMER_EVT = 1; 42 I2C1_Init_Advanced(400000, &_GPIO_MODULE_I2C1_PB67); 43 delay_ms(200); 44 } 45 46 void main() { 47 MCU_Init(); 48 timer_hal_init(DS1682_I2C_Adr); 49 Display_Init(); 50 #ifdef CountFromZero 51 timer_set_ec_value(0); 52 timer_set_etc_value(0); 53 TIMER_EVT = 0; 54 delay_ms(100); 55 TIMER_EVT = 1; 56 delay_ms(100); 57 #endif 58 while(1) { 59 delay_ms(2000); 60 TFT_Rectangle(100,10,200,40); 61 TFT_Rectangle(80,50,200,80); 62 //Event counter 63 EC = timer_Get_ec_Value(); 64 WordToStr(EC,text); 65 TFT_Write_Text(text,100,10); 66 //Time counter - in quarter seconds 67 ETC = timer_get_etc_value(); 68 LongWordToStr(ETC,text); 69 TFT_Write_Text(text,100,50); 70 } 71 72 }
Code examples that demonstrate the usage of Timer click with MikroElektronika hardware, written for mikroC for ARM, FT90x, and PIC are available on Libstock