nRF51 Example 9 - PPI

Source Demo

ppi0

My Demo

Add Serial Port to feedback data.
ppi

Please click “more” on the right!

Part of my source files

main.c

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "nrf51.h"
#include "led.h"
#include "time.h"
#include "ppi.h"
#include "nrf_delay.h"
#include "nrf_gpio.h"
#include "uart.h"
int main(void)
{
uint8_t lastCC0;
bool isStop;
timer0_init();
timer1_init();
timer2_init();
ppi_init();
USART_Configuration();
NRF_POWER->TASKS_CONSTLAT = 1;
// Start clock.
NRF_TIMER1->TASKS_START = 1;
NRF_TIMER2->TASKS_START = 1;
nrf_gpio_range_cfg_output(LED_START, LED_STOP);
printf("Hi Fabacademy!\r\n");
while (1)
{
NRF_TIMER0->TASKS_COUNT = 1;
NRF_TIMER0->TASKS_CAPTURE[0] = 1;
if ((uint8_t)NRF_TIMER0->CC[0] == lastCC0) {
//Task was stopped!
if (!isStop) {
isStop = 1;
printf("Task was stopped! \r\n");
}
}else{
//Task is Running!
isStop = 0;
printf("Task was started! \r\n");
printf("CC[0] value is %u \r\n",(uint8_t)NRF_TIMER0->CC[0]);
}
lastCC0 = (uint8_t)NRF_TIMER0->CC[0];
nrf_gpio_port_write(NRF_GPIO_PORT_SELECT_PORT2, (uint8_t)NRF_TIMER0->CC[0]);
nrf_delay_ms(50);
}
}

Download my files


This work is licensed under a Creative Commons Attribution 4.0 International License.