Learn MoreFAQsTutorials

2 posts / 0 new
Last post
build77
Offline
Last seen:6 days 3 hours ago
加入:2015-02-17 02:32
HW PWM with BLE

I am using Da14699 development kit with sdk version 10.0.10.118

I want to use hw pwm (HW_TIMER or HW_TIMER2) with PIO1.1 or 1.6 and BLE.

The PWM freq will set 1MHz or 2MHz. (must be act when Extended sleep)

After modify PXP_Reporter Demo source code, and PWM works fine, but can't connect BLE.

静态孔隙periph_init(空白)
{
#if defined CONFIG_RETARGET
#endif

#if (dg_configUSE_SYS_CHARGER == 1)
/* USB data pin configuration */
hw_gpio_set_pin_function(HW_GPIO_PORT_0, HW_GPIO_PIN_14, HW_GPIO_MODE_INPUT, HW_GPIO_FUNC_USB);
hw_gpio_set_pin_function(HW_GPIO_PORT_0, HW_GPIO_PIN_15, HW_GPIO_MODE_INPUT, HW_GPIO_FUNC_USB);
#endif /* dg_configUSE_SYS_CHARGER */
// HW_GPIO_SET_PIN_FUNCTION(LED1);

#if defined LSU_CLK_Test

hw_gpio_set_pin_function(HW_GPIO_PORT_1, HW_GPIO_PIN_1, HW_GPIO_MODE_OUTPUT, HW_GPIO_FUNC_TIM_PWM);
hw_gpio_pad_latch_enable (HW_GPIO_PORT_1, HW_GPIO_PIN_1);

hw_gpio_set_pin_function(HW_GPIO_PORT_1, HW_GPIO_PIN_6, HW_GPIO_MODE_OUTPUT, HW_GPIO_FUNC_TIM2_PWM);
hw_gpio_pad_latch_enable (HW_GPIO_PORT_1, HW_GPIO_PIN_6);
#endif

}

void pxp_reporter_task(void *params)
{
int8_t tx_power_level;
int8_t wdog_id;
#if dg_configSUOTA_SUPPORT
ble_service_t *suota;
#endif
uint16_t name_len;
char name_buf[MAX_NAME_LEN + 1]; /* 1 byte for '\0' character */

/* Scan Response object to be populated with AD type */
gap_adv_ad_struct_t *scan_rsp;

/* Register pxp_reporter_task to be monitored by watchdog */
wdog_id = sys_watchdog_register(false);
............

.............

#if defined LSU_CLK_Test

timer_config cfg = {
.clk_src = HW_TIMER_CLK_SRC_EXT,
.prescaler = 0,
.mode = HW_TIMER_MODE_TIMER,
.timer = {
.direction = HW_TIMER_DIR_UP,
.reload_val = 0,
.free_run = true,
},

.pwm = {
.port = HW_GPIO_PORT_1,
.pin = HW_GPIO_PIN_1,
.pwm_active_in_sleep = true,
.duty_cycle = 8,
.frequency = 15,
},
};

timer_config cfg2 = {
.clk_src = HW_TIMER_CLK_SRC_EXT,
.prescaler = 0,
.mode = HW_TIMER_MODE_TIMER,
.timer = {
.direction = HW_TIMER_DIR_UP,
.reload_val = 0,
.free_run = true,
},

.pwm = {
.port = HW_GPIO_PORT_1,
.pin = HW_GPIO_PIN_6,
.pwm_active_in_sleep = true,
.duty_cycle = 8,
.frequency = 15,
},
};

hw_timer_init(HW_TIMER, &cfg);
hw_timer_init(HW_TIMER2, &cfg2);
hw_timer_enable(HW_TIMER);
hw_timer_enable(HW_TIMER2);

#endif

current_task = OS_GET_CURRENT_TASK();

printf("\r\n pxp_reporter_task.\r\n");

for (;;) {
OS_BASE_TYPE ret __UNUSED;
uint32_t notif;

..........

..........

Is any limitation BLE with HW PWM?

Thank you.

Lee

Device:
PM_Dialog
Offline
Last seen:11 hours 3 min ago
Staff
加入:2018-02-08 11:03
Hi bojanpotocnik,

Hi bojanpotocnik,

The HW_TIMER2 is used by the FreeRTOS so you cannot use in your application.

You are using TIMER2 which is used for the OS-TICK. By changing this, you mess-up all the FreeRTOS. This is described in our documentation as well. You can use the TIMER2 for PWM for example BUT NOT re-configure it.

If you want to use HW timer, then you can use TIMER (aka TIMER1) or TIMER3 or TIMER4. TIMER1 and TIMER2 are the only ones available in sleep. Please see datasheet for more info.

Could you please also run it in debug mode? Are you getting any assertion? If the TIMER2 is removed, then can you please check if the code is running properly?

Thanks, PM_Dialog