The software timer of nrf51822 just doesn't work
[Copy link]
The code is not difficult, I hope there are experts to help me. Thanks!
Busy
#include <stdint.h>
#include "nrf_delay.h"
#include "nrf_gpio.h"
#include "app_timer.h"
//#include "app_scheduler.h"
APP_TIMER_DEF(testapp_timer_id);
static void leds_init(void)
{
nrf_gpio_cfg_output(17);//P0.17
nrf_gpio_pin_clear(17); //17ר1
nrf_gpio_cfg_output(18);//P0.17
nrf_gpio_pin_set(18);
nrf_gpio_cfg_output(19);//P0.17
nrf_gpio_pin_set(19);
}
static void k_timeout_handler(void * p_context)
{
UNUSED_PARAMETER(p_context);
// battery_level_update();
nrf_gpio_pin_toggle(17);
}
static void timers_init(void)
{
// Initialize timer module, making it use the scheduler
APP_TIMER_INIT(0, 0, false); //í¨±
uint32_t err_code; //¨¨± ·
err_code=app_timer_create(&testapp_timer_id,APP_TIMER_MODE_SINGLE_SHOT,k_timeout_handler);
APP_ERROR_CHECK(err_code);
app_timer_start(testapp_timer_id, APP_TIMER_TICKS(1000,0), NULL);
}
int main(void)
{
leds_init(); //
timers_init();
while (true)
{
}
}
|