| BlueNRG-1 Peripherals drivers Examples

- Main Page
- Modules
- Classes
- Files

- File List
- File Members

Macros | Functions
RTC_Clockwatch_main.c File Reference

This example demonstrates how the RTC clockwatch could be used to generate and interrupt in specific date and time. More...

`#include "BlueNRG1.h"`
`#include "BlueNRG1_conf.h"`
`#include "SDK_EVAL_Config.h"`

Go to the source code of this file.

## Macros

#define | SET_HOUR 23 /*< Set hour to the RTC */
#define | SET_MINUTE 59 /*< Set minute to the RTC */
#define | SET_SECOND 31 /*< Set second to the RTC */
#define | SET_WEEKDAY 7 /*< Set weekday to the RTC */
#define | SET_DAY 1 /*< Set day to the RTC */
#define | SET_MONTH 12 /*< Set month to the RTC */
#define | SET_YEAR 2014 /*< Set year to the RTC */
#define | MATCH_HOUR 00 /*< Match hour to generate interrupt */
#define | MATCH_MINUTE 00 /*< Match minute to generate interrupt */
#define | MATCH_SECOND 01 /*< Match second to generate interrupt */
#define | MATCH_WEEKDAY 01 /*< Match weekday to generate interrupt */
#define | MATCH_DAY 02 /*< Match day to generate interrupt */
#define | MATCH_MONTH 12 /*< Match month to generate interrupt */
#define | MATCH_YEAR 2014 /*< Match year to generate interrupt */
#define | RTC_PERIOD_500ms ((32768-1)/2)

## Functions

void | RTC_Timer_Configuration (void)
| RTC Configuration. More...
void | RTC_Clockwatch_Configuration (void)
| RTC clockwatch configuration. More...
int | main (void)
| Main program code. More...

## Detailed Description

This example demonstrates how the RTC clockwatch could be used to generate and interrupt in specific date and time.

# ATOLLIC project

To use the project with ATOLLIC TrueSTUDIO for ARM, please follow the instructions below:

1. Open the ATOLLIC TrueSTUDIO for ARM and select File->Import... Project menu.
2. Select Existing Projects into Workspace.
3. Select the ATOLLIC project
4. Select desired configuration to build from Project->Manage Configurations
5. Select Project->Rebuild Project. This will recompile and link the entire application
6. To download the binary image, please connect STLink to JTAG connector in your board (if available).
7. Select Project->Download to download the related binary image.
8. Alternatively, open the BlueNRG1 GUI, put the board in bootloader mode and download the built binary image.

# KEIL project

To use the project with KEIL uVision 5 for ARM, please follow the instructions below:

1. Open the KEIL uVision 5 for ARM and select Project->Open Project menu.
2. Open the KEIL project `...\Project\BlueNRG1_Periph_Examples\RTC\Clockwatch\MDK-ARM\Clockwatch.uvprojx`
3. Select desired configuration to build
4. Select Project->Rebuild all target files. This will recompile and link the entire application
5. To download the binary image, please connect STLink to JTAG connector in your board (if available).
6. Select Project->Download to download the related binary image.
7. Alternatively, open the BlueNRG1 GUI, put the board in bootloader mode and download the built binary image.

# IAR project

To use the project with IAR Embedded Workbench for ARM, please follow the instructions below:

1. Open the Embedded Workbench for ARM and select File->Open->Workspace menu.
2. Open the IAR project `...\Project\BlueNRG1_Periph_Examples\RTC\Clockwatch\EWARM\Clockwatch.eww`
3. Select desired configuration to build
4. Select Project->Rebuild All. This will recompile and link the entire application
5. To download the binary image, please connect STLink to JTAG connector in your board (if available).
6. Select Project->Download and Debug to download the related binary image.
7. Alternatively, open the BlueNRG1 GUI, put the board in bootloader mode and download the built binary image.

## Project configurations

- `Release` - Release configuration

# Boards supported

- `STEVAL-IDB007V1`

# Power configuration settings

STEVAL-IDB007V1
Jumper name |  | Description
JP1 | JP2 |
ON 1-2 | ON 2-3 | USB supply power
ON 2-3 | ON 1-2 | The supply voltage must be provided through battery pins.
ON 1-2 |  | USB supply power to STM32L1, JP2 pin 2 external power to BlueNRG1

# Jumper settings

STEVAL-IDB007V1
Jumper name | Description
JP1 | 1-2: to provide power from USB (JP2:2-3). 2-3: to provide power from battery holder (JP2:1-2)
JP2 | 1-2: to provide power from battery holder (JP1:2-3). 2-3: to provide power from USB (JP1:1-2). Pin2 to VDD to provide external power supply to BlueNRG-1 (JP1: 1-2)
JP3 | pin 1 and 2 UART RX and TX of MCU. pin 3 GND.
JP4 | Fitted: to provide VBLUE to BlueNRG1. It can be used also for current measurement.
JP5 | Fitted : TEST pin to VBLUE. Not fitted: TEST pin to GND

# Pin settings

PIN name | STEVAL-IDB007V1
ADC1 | Not Used
ADC2 | Not Used
IO0 | Not Used
IO1 | Not Used
IO11 | Not Used
IO12 | Not Used
IO13 | Not Used
IO14 | Not Used
IO2 | Not Used
IO3 | Not Used
IO4 | Not Used
IO5 | Not Used
IO6 | Drive the LED DL1
IO7 | Drive the LED DL2
IO8 | Not Used
TEST1 | Not Used

# LEDs description

LED name | STEVAL-IDB007V1
DL1 | Toggle
DL2 | Toggle
DL3 | Not Used
DL4 | Power

# Buttons description

BUTTON name | STEVAL-IDB007V1
PUSH1 | Not Used
PUSH2 | Not Used
RESET | Reset BlueNRG1

# Usage

The BlueNRG1 embeds a real-time counter RTC clocked by the RC32K and can still run in low-power modes. The RTC provides to the user real-time clockwatch functionality and a real-time clock timer. The RTC clockwatch consists of two counters and two alarm registers that have the following features.

Two counters:

- Counts seconds, minutes, hours, days of the week, days of the month.
- Counts years.

Two alarm registers:

- Can be used to trigger an interrupt or device wake-up at an exact date and time.

The RTC timer is a 32-bit free-running counter, clocked by the 32 kHz clock signal (from an embedded 32 kHz RC), that could work in periodic or single shot mode.

In this example, both RTC timer and RTC clockwatch are used.

The RTC timer is setup for the period interrupt generation. It generates interrupt each 500ms. The LED1 state is toggled in the RTC interrupt handler. It is used to signal that the RTC timer is functional and running.

The RTC clockwatch is also configured and enabled. The system time and date is set to 1 st of December 2014, 23 hour 59 min and 31 seconds. Then the RTC clockwatch match registers are set to 2nd of December 2014, 0 hour 0 min and 1 second. As soon as the match between RTC clockwatch data register the clockwatch match register occur (30s after the device power up) the RTC clockwatch match interrupt is generated and the LED2 is set to signal the event.

Definition in file RTC_Clockwatch_main.c.