3, PWM two-channel output production of breathing lights (with a variety of driving engineering)

Source: Internet
Author: User

A project with various drives, with the function of driving function in main function

C:\Users\LiTao\Desktop\ Children Intelligent Hardware Data \MY_WORKSPACE\PWM

The transformation realizes the PWM two outputs

1#include <stdbool.h>2#include <stdint.h>3#include"Nrf_delay.h"4#include"nrf_gpio.h"5#include"Boards.h"6#include"nrf_pwm.h"7 8 /**9 * @brief Function for application main entry.Ten  */ One intMainvoid) A { - uint8_t t; -  thenrf_pwm_config_t Pwm_config =pwm_default_config;// -      -Pwm_config.mode = pwm_mode_led_255; //  8-bit resolution, 122Hz PWM frequency, 32kHz Timer frequency (prescaler 9)  -Pwm_config.num_channels =2; +pwm_config.gpio_num[0] = Led_0; // This is set to use which IO port as PWM output    -pwm_config.gpio_num[1] = Led_1; // This is set to use which IO port as PWM output  +      ANrf_pwm_init (&pwm_config);//PWM Initialization at      -     //Configure Led-pins as outputs - Nrf_gpio_cfg_output (led_0); - Nrf_gpio_cfg_output (led_1); -  -  in      -     //led 0 and led 1 blink alternately. tot=1; +      while(true) -     {   thet=t+1; *Nrf_pwm_set_value (0, T);  $Nrf_delay_ms ( -);Panax Notoginseng           -          the         if(t> $) t=0;  + //Nrf_pwm_set_value (1, +); A     } the}

nrf_pwm_config_t pwm_config = pwm_default_config; [M1]

[M1] PWM structural body

Pwm_config.mode = pwm_mode_led_255; 8-bit resolution, 122Hz PWM frequency, 32kHz timer [M1] Frequency (prescaler 9)

[M1] Setting the PWM mode

Pwm_config.num_channels = 2;

Pwm_config.gpio_num[0] = led_0; This is set to use which IO port as the PWM output

PWM_CONFIG.GPIO_NUM[1] = led_1; This setting uses which IO port to use as the PWM output [M1]

[M1] PWM two channels

Nrf_pwm_init (&pwm_config); PWM initialization [M1]

[M1] Initialize PWM

Nrf_pwm_set_value (0, T); [M1]

[M1] Set the duty ratio of channel 0 to T, full to 255, see mode above

Links: HTTP://PAN.BAIDU.COM/S/1I3VT7CP

3, PWM two-channel output production of breathing lights (with a variety of driving engineering)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.