| BlueNRG-1 Peripherals drivers Examples

- Main Page
- Modules
- Classes
- Files

- File List
- File Members

Functions
WDG_Reset_main.c File Reference

This code provides an example how the watchdog timer works and how it could be used to reset the system if the watchdog interrupt flag is not cleared within the watchdog timeout period. More...

`#include "BlueNRG1.h"`
`#include "BlueNRG1_it.h"`
`#include "BlueNRG1_conf.h"`
`#include "SDK_EVAL_Config.h"`
`#include <stdio.h>`

Go to the source code of this file.

## Functions

void | WDG_Configuration (void)
| WDG configuration routine. More...
void | MFT_Configuration (void)
| MFT configuration routine. More...
int | main (void)
| Main program code. More...

## Detailed Description

This code provides an example how the watchdog timer works and how it could be used to reset the system if the watchdog interrupt flag is not cleared within the watchdog timeout period.

# 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\WDG\Reset\MDK-ARM\Reset.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\WDG\Reset\EWARM\Reset.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 | External interrupt from PUSH1
IO14 | Drive the LED DL3
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 | Toggle
DL4 | Power

# Buttons description

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

# Usage

The watchdog timer is a 32-bit down counter that divides the clock input (32.768 kHz) to produce an interrupt. A watchdog interrupt is generated each time the counter reaches 0. The counter is then reloaded with the content of the WDT_LR register. If the interrupt status flag is not cleared and a new interrupt is generated then the watchdog could generate a reset to reboot the system.

This example demonstrates the watchdog functionality and the possibility to use it to reboot the system when the watchdog interrupt is not serviced during the watchdog period (interrupt status flag is not cleared).

The watchdog is configured to generate the interrupt with period of 15s and then it is enabled. Then the PUSH1 button, IO13 pin, state is watched. Any change of this pin triggers the watchdog counter reload and restart of the 15s period measurement.

If the IO13 pin state does not change during this 15s period the watchdog generates an interrupt that is intentionally not cleared. Therefore, the interrupt remains pending, and for that reason the watchdog interrupt service routine is called continuously, the system is stuck in the watchdog interrupt handler. It can no more proceed with the user code execution and this reset the chip. Once the watchdog timeout occurs, the second time the system reboot is triggered as a new watchdog interrupt is generated in the time when the previous interrupt is still pending. Then the application starts again to measure the 15s period.

The three user LEDs are toggled with increased rates until the board is reset. The user must press the PUSH1 button to avoid the reset of the board. Once the PUSH1 button is pressed, the LEDs toggling speed is restored with the 15s watchdog timer.

Definition in file WDG_Reset_main.c.