了解更多常见问题解答教程

2个帖子/ 0新
最后一篇
Build77.
离线
最后一次露面:2天前1周
加入:2015-02-17 02:32
HW PWM带BLE

我正在使用DA14699开发套件,SDK版本10.0.10.118

我想使用带有Pio1.1或1.6和BLE的HW PWM(HW_TIMER或HW_TIMER2)。

PWM FREQ将设置1MHz或2MHz。(延长睡眠时必须采取行动)

修改PXP_Reporter演示源代码后,PWM工作正常,但无法连接BLE。

静电void periph_init(空白)
{
#if定义了config_retarget.
#万一

#if(dg_configuse_sys_charger == 1)
/ * USB数据引脚配置* /
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);

#f定义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);
#万一

}

void pxp_reporter_task(void * params)
{
INT8_T TX_POWER_LEVEL;
Int8_t wdog_id;
#if dg_configsuota_support.
ble_service_t * suota;
#万一
uint16_t name_len;
char name_buf [max_name_len + 1];/ *'\ 0'字符的1字节* /

/ *扫描响应对象以<完成本地名称>广告类型* /
gap_adv_ad_struct_t * scan_rsp;

/ *寄存器pxp_reporter_task由看门狗监视* /
wdog_id = sys_watchdog_register(false);
............

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

#f定义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);

#万一

current_task = os_get_current_task();

printf(“\ r \ n pxp_reporter_task。\ r \ n”);

为了 (;;) {
OS_BASE_TYPE RET __UNUSED;
uint32_t notif;

..........

..........

是否用HW PWM限制了?

谢谢你。

设备:
PM_DIALOG.
在线的
最后一次露面:2分钟29秒前
职员
加入:2018-02-08 11:03
嗨bojanpotocnik,

嗨bojanpotocnik,

FREERTOS使用HW_TIMER2,因此您无法在应用程序中使用。

您使用的是Timer2,它用于OS-rect。通过改变这个,你搞砸了所有的freertos。这也在我们的文档中描述。例如,您可以使用Timer2为PWM但不重新配置它。

如果要使用HW计时器,则可以使用计时器(AKA Timer1)或Timer3或Timer4。Timer1和Timer2是睡眠中唯一可用的。请参阅数据表更多信息。

你还可以在调试模式下运行它吗?你有任何断言吗?如果删除Timer2,那么您是否可以检查代码是否正常运行?

谢谢,PM_DIALOG.