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)