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
#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.

文章目录
  1. 1. Source Demo
  2. 2. My Demo
  3. 3. Part of my source files
    1. 3.1. main.c
,