十三、nrf52832的systick

systick
1.nrf52832的systick的定时为无中断,阻塞式的
2.systick可以实现较高精度的定时(us)
systick常见函数
1.systick初始化函数:nrfx_systick_init()
2.systick ms级延时函数:nrfx_systick_delay_ms(ms)
3.systick us级延时函数:nrfx_systick_delay_us(us)
systick示例程序
#include <stdbool.h>
#include <stdint.h>
#include "nrf_delay.h"
#include "boards.h"

#include "nrf_log.h"
#include "nrf_log_ctrl.h"
#include "nrf_log_default_backends.h"

#include "nrf_drv_systick.h"

static void log_init(void)
{
	ret_code_t err = NRF_LOG_INIT(NULL);
	APP_ERROR_CHECK(err);
	NRF_LOG_DEFAULT_BACKENDS_INIT();
}

int main(void)
{
	log_init();
	nrf_gpio_cfg_output(17);								//gpio初始化为输出模式,P0.17
	nrf_gpio_pin_set(17);									//初始gpio电平状态为高电平
	nrf_gpio_cfg_output(18);								//gpio初始化为输出模式,P0.17
	nrf_gpio_pin_set(18);									//初始gpio电平状态为高电平

	nrfx_systick_init();

	NRF_LOG_INFO("GPIO example started");
	NRF_LOG_FLUSH();
	
	while(1)
	{
		nrf_gpio_pin_set(18);
		nrfx_systick_delay_ms(2000);
		nrf_gpio_pin_clear(18);							
		nrfx_systick_delay_ms(2000);
	}
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值