Hello to all,
Since a couple of weeks I have a problem in a program which consist of three parts:
1.- a Timer to make a pulse train by interrupts 2.- a program to control a LCD display 3.- a program to set and clear a led and to read a button via bluetooth.
All works fine while the part of the timer to generate a pulse train is disabled, but when I enable it, all my signals in the output pins from the another parts of the program go to zero, and I have no idea what it's happening. The timer configuration I've used is the next:
// Start 16 MHz crystal oscillator.
NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
NRF_CLOCK->TASKS_HFCLKSTART = 1;
// Wait for the external oscillator to start.
while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0)
{
// Do nothing.
}
// Clear TIMER2
NRF_TIMER2->TASKS_CLEAR = 1;
// Configure TIMER2 for compare[0] event every 200 ms.
NRF_TIMER2->PRESCALER = 4; // Prescaler 4 results in 1 tick equals 1 microsecond.
NRF_TIMER2->CC[0] = 1*1000UL; // 1 tick equals 1µ , multiply by 1000 for ms value.
NRF_TIMER2->MODE = TIMER_MODE_MODE_Timer;
NRF_TIMER2->BITMODE = TIMER_BITMODE_BITMODE_24Bit;
NRF_TIMER2->SHORTS = (TIMER_SHORTS_COMPARE0_CLEAR_Enabled <INTENSET = (TIMER_INTENSET_COMPARE0_Enabled <'ve used is the next:
uint32_t err_code;
nrf_gpio_cfg_output(GPIO_OUTPUT_PIN_NUMBER);
timer2_init(); // Use TIMER2 to generate events every 200 ms.
// Enable TIMER2 interrupt
err_code = sd_nvic_ClearPendingIRQ(TIMER2_IRQn);
APP_ERROR_CHECK(err_code);
err_code = sd_nvic_SetPriority(TIMER2_IRQn, NRF_APP_PRIORITY_HIGH);
APP_ERROR_CHECK(err_code);
err_code = sd_nvic_EnableIRQ(TIMER2_IRQn);
APP_ERROR_CHECK(err_code);
NRF_TIMER2->TASKS_START = 1; // Start event generation.
Is the configuration of the timer interrupts correct???
The libraries I'm using are the next:
include stdint.h
include string.h
include "nordic_common.h"
include "nrf.h"
include "app_error.h"
include "nrf_gpio.h"
include "nrf51_bitfields.h"
include "boards.h"
include "app_timer.h"
include "app_gpiote.h"
include "app_button.h"
include "spi_master.h"
include "spi_master_config.h"
include "nrf_delay.h"
include "boards.h"
include "nrf_gpiote.h"