⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.xmece.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
3 posts / 0 new
Last post
jagath52
Offline
Last seen:1 month 3 weeks ago
加入:2020-07-06 10:40
Driving gpio with pwm

Hello,

I am using Da14695 usb development kit with WiRa Sdk version WiRa_10.440.8.6.

I want to use gpios such as P0_17 or P0_18 for pwm timer with Timer3 and Timer4 but didn't get the output.

With the help of timer example i am able to use P1_1 and P1_6 with Timer and Timer2 but i want to use P0_ 17 and P0_18 as Pwm.

i modified Timer example as

(In this sleep mode is set to pm_mode_active mode)

#define TIMER1_PWM_PORT HW_GPIO_PORT_0

#define TIMER1_PWM_PIN HW_GPIO_PIN_18

static void prvSetupHardware( void )
{

/* Init hardware */
pm_system_init(periph_init);

/* Enable the COM power domain before handling any GPIO pin */
hw_sys_pd_com_enable();

/* PWM functionality */
hw_gpio_set_pin_function(TIMER1_PWM_PORT, TIMER1_PWM_PIN, HW_GPIO_MODE_OUTPUT, HW_GPIO_FUNC_TIM3_PWM);
hw_gpio_pad_latch_enable (TIMER1_PWM_PORT, TIMER1_PWM_PIN);
hw_gpio_pad_latch_disable(TIMER1_PWM_PORT, TIMER1_PWM_PIN);

/* Disable the COM power domain after configuring all the GPIO pins */
hw_sys_pd_com_disable();

}

void _timer_init(HW_TIMER_ID id)
{
timer_config cfg = {

.clk_src = HW_TIMER_CLK_SRC_EXT,
.prescaler = 31,

.mode = HW_TIMER_MODE_TIMER,

/* Configure TIMER in capture mode */
.timer = {
.direction = HW_TIMER_DIR_UP,

.reload_val = 0,
.free_run = true,

},

/* Configure PWM functionality */
.pwm = {
.port = TIMER1_PWM_PORT,
.pin = TIMER1_PWM_PIN,

.pwm_active_in_sleep = true,
.frequency = 64999,
.duty_cycle = 32500,
},
};

hw_timer_init(id, &cfg);
hw_timer_register_int(id, _timer_overflow_cb);

}

void prvTimersTask( void *pvParameters )
{
printf("*** TIMER3 Demonstration ***\n\r");

_timer_init(HW_TIMER3);

hw_timer_enable(HW_TIMER3);

for (;;) {
}

}

Is the timer configuration is correct or any thing need to add.

每个gpio的只能用作Pwm或specific gpios .

how to use gpio P0_17 as Pwm timer.

Thank you

Jagath

Device:
IM_Dialog
Offline
Last seen:1 month 3 weeks ago
加入:2016-12-06 22:25
Hi Jagath,

Hi Jagath,

Because only P1_1 and P1_6 can provide a PWM output while the device is in sleep mode, when you use any other GPIO as a PWM output you must set the pwm_active_in_sleep variable in the PWM configuration structure to false, as follows:

/* Configure PWM functionality */ .pwm = { .port = TIMER1_PWM_PORT, .pin = TIMER1_PWM_PIN, /* * When set to true, TIMER1 will keep generating PWM pulses on P1_1 pin, * whilst, TIMER2 on P1_6 pin during sleep mode. */.pwm_active_in_sleep = false,

Best regards
IM_Dialog

jagath52
Offline
Last seen:1 month 3 weeks ago
加入:2020-07-06 10:40
Thank you

Thank you