Hi Nordic Team, i am working on nrg52 to glow a RGB LED with white and Yellow colours. configured the RGB pins to three different Gpio (A2,A3,A4).
for this i am using PWM library example in which i can only configure 2 channel(2 pins) to drive PWM to Gpio pins. if i configure red and green pins using PWM i unable to get yellow color.
i am getting mixed colour of red,green, yellow. at wt fre quency(time period) i should operate PWM to get pure Yellow colour, and also how i can configure 3 pins to drive PWM using PWM library example.
here is my code.
APP_PWM_INSTANCE(pwm_library,1); // Create the instance "PWM1" using TIMER1.
static volatile bool ready_flag; // A flag indicating PWM status.
void pwm_ready(uint32_t pwm_id) // PWM callback function
{
ready_flag = true;
}
uint32_t time_period = 2000L;
int main(void)
{
ret_code_t err_code;
printf("VIBRATION:\r\n");
/* 2-channel PWM, 200Hz, output on DK LED pins. */
app_pwm_config_t pwm1_cfg = APP_PWM_DEFAULT_CONFIG_2CH(time_period, ARDUINO_2_PIN,ARDUINO_A4_PIN);
/* Switch the polarity of the second channel. */
pwm1_cfg.pin_polarity[1] = APP_PWM_POLARITY_ACTIVE_HIGH;
pwm1_cfg.pin_polarity[0] = APP_PWM_POLARITY_ACTIVE_HIGH;
/* Initialize and enable PWM. */
err_code = app_pwm_init(&pwm_library,&pwm1_cfg,pwm_ready);
APP_ERROR_CHECK(err_code);
app_pwm_enable(&pwm_library);
while(true){
for(int i = 0; i<= 100; i++){
app_pwm_channel_duty_set(&pwm_library, 0, i);
nrf_delay_ms(100);
}
}
}