Include the app_timer.h file in your main.c file.While (NRF_CLOCK->EVENTS_LFCLKSTARTED = 0) NRF_CLOCK->LFCLKSRC = (CLOCK_LFCLKSRC_SRC_RC EVENTS_LFCLKSTARTED = 0 Create a function called lfclk_init() where you add the following snippet. Hence, we'll need to start the LFCLK for the application timer to function properly. As mentioned in the introduction of this task, the application timer uses the RTX peripheral, which in turn uses the 32kHz LFCLK.The Application Timer library API is documented here By using the 12 bit (1/X) prescaler the frequency of the RTC can be lowered if needed. As the clock is 32.768 kHz and the RTC is 24 bit, the time/tick resolution is limited, but it takes a substantial amount of time before the counter wrap around from (0xFFFFFF to 0x000000). Therefore, there is normally very little extra power consumption associated with using the application timer. Most applications keep the LFCLK active at all times and when using one of the Nordic SoftDevices the LFCLK is always active. The RTC uses the Low Frequency Clock (LFCLK). The Application Timer library provides a user friendly way of using the Real Time Counter 1 (RTC1) peripheral to create multiple timer instances. A much better approach would be to set up a timer to toggle the LED at a given interval so that the CPU can do meaningful tasks or sleep in between the timer interrupts. Use nrf_delay_ms() and nrf_gpio_pin_toggle() to blink an LED within the while-loop in main().īlinking an LED with a busy-wait loop is not very efficient, as you'll keep the CPU running without actually doing anything useful.Hint: See the back of the nRF52 DK for the pin assignments. Use the nrf_gpio_cfg_output() function to configure one of the pins connected to one of the LEDs of the nRF52 DK as an output.Include the following headers in main.c.Goal: Blink an LED by keeping the CPU in a busy-wait loop. Remove the nRF_micro_ecc library (micro_ecc_lib_nrf52.a) file from the nRF_micro-ecc folder in the project explorer view on the left hand side.Open the template_pca10040.emProject Segger Embedded Studio project found in nRF52_peripherals_tutorial\pca10040\blank\ses.Create a copy of the template_project folder and rename it to nRF52_peripherals_tutorial.Find the template_project from nRF5_SDK_15.3.0_59ac345\examples\peripheral\template_project.The template project includes all the peripheral libraries and drivers from the SDK, but we're only going to use a few, so to reduce the compile time and size of our project, we'll temporarily remove them from the project. Some of the drivers are found in SDK\modules\nrfx\drivers\src Warm-up nrf_drv_xxx.c, which can be found in nRF5_SDK_14.1.0_1dda907\components\drivers_nrf\ and nRF5_SDK_14.1.0_1dda907\components\libraries respectively. In all the tasks we'll be using the SDK drivers or libraries for the peripherals, i.e. Template project found in nRF5_SDK_15.3.0_59ac345\examples\peripheral\template_project.Configure a timer to toggle a gpio pin to interact autonomously with each other using tasks and events independent of the CPU Automate peripheral using the tasks and event system.Send serial data to and from a terminal window. Generate a PWM pulse that is used to control an analog servo.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |