Hi
This is in part related to my previous post on PWM signal generation on two channels that are 90 degree phase shifted. The frequency of the PWM signal generated was not large enough for the application required (It is required to generate in Mega Hz.). Thus, I had to use the 16MHz base frequency, and lower down the top count value to 3 (I tried to use top value= 1 and 2 but no PWM signal was generated, at least in up count mode). The following configuration let me to generate a PWM signal at ~5.3MHz on both the channels, which is good.
nrf_drv_pwm_config_t const pwm_cfg = { .output_pins = { 9, // channel 0 10, // channel 1 NRF_DRV_PWM_PIN_NOT_USED, // channel 2 NRF_DRV_PWM_PIN_NOT_USED, // channel 3 }, .irq_priority = APP_IRQ_PRIORITY_LOWEST, .base_clock = NRF_PWM_CLK_16MHz, .count_mode = NRF_PWM_MODE_UP, .top_value = 3, .load_mode = NRF_PWM_LOAD_INDIVIDUAL, .step_mode = NRF_PWM_STEP_AUTO }; APP_ERROR_CHECK(nrf_drv_pwm_init(&m_pwm0, &pwm_cfg, NULL)); static nrf_pwm_values_individual_t seq_values[] = { {1, 1, 0, 0}, }; nrf_pwm_sequence_t const seq = { .values.p_individual = seq_values, .length = NRF_PWM_VALUES_LENGTH(seq_values), .repeats = 0, .end_delay = 0 }; nrf_drv_pwm_simple_playback(&m_pwm0, &seq, 1, NRF_DRV_PWM_FLAG_LOOP);
My problem now is to get the 90 degree phase shifting right. I tried to fed different sequences but couldn't succeed in a good result. The following sequence generated the 90 degree shifted signals, but the frequency droped drastically to ~380kHz (My expectation was something ~1.3MHz).
static nrf_pwm_values_individual_t seq_values[] = { {3, 3, 3, 0}, {3, 3, 0, 3}, {3, 0, 3, 3}, {0, 3, 3, 3} } ;
So, how can this be achieved? Is this something I can't achieve using PWM module? If this can't be achieved by the PWM drive, or by the PWM library, is there some other way I can generate phase shifted high frequency signals on two pins using nrf52832? Examples are appreciated!