pwm 50hz的频率测试正常

This commit is contained in:
lmx
2025-12-21 18:27:34 +08:00
parent 8cb1ca7701
commit 482767064e
12 changed files with 126 additions and 25 deletions

View File

@ -28,7 +28,7 @@ extern "C" {
#include "gpio.h"
static uint8_t LL_led = 0;
#define LLSYNC_SWITCH_PIN IO_PORTA_01
#define LLSYNC_SWITCH_PIN IO_PORTA_00
static int ble_property_power_switch_set(const char *data, uint16_t len)
{
printf("ble_property_power_switch_set led to %d\n", data[0]);

View File

@ -0,0 +1,89 @@
#include "asm/mcpwm.h"
#include "asm/gpio.h"
#include "task_func.h"
#include "./nvs/nvs.h"
#include "timer.h"
#include "system/includes.h"
#include "user_cfg.h"
#include "earphone.h" // 宏定义 EARPHONE_STATE_...
#include "ble_user.h"
#include "le_client_demo.h"
#include "le_common.h"
#include "./ble_handler/client_handler.h"
#include "./RFID/include/rfid_main.h"
#include "./RFID/include/READER_REG.h"
/*
* PWM配置参数:
* - 周期: 50ms (20Hz)
* - 最小脉宽: 500us (1%占空比)
* - 最大脉宽: 2.5ms (5%占空比)
* - PWM引脚: PA1 (IO_PORTA_01)
*/
void pwm_test_init(void)
{
struct pwm_platform_data pwm_data = {0};
// 配置PWM参数
pwm_data.pwm_aligned_mode = pwm_edge_aligned; // 边沿对齐模式
pwm_data.pwm_ch_num = pwm_ch0; // 使用PWM通道0
pwm_data.frequency = 50; // 20Hz (周期50ms)
pwm_data.duty = 100; // 初始占空比1% (500us/50ms = 1%)
pwm_data.h_pin = IO_PORTA_01; // PWM输出引脚PA1
pwm_data.l_pin = -1; // 不使用互补引脚
pwm_data.complementary_en = 0; // 非互补模式
// 初始化PWM
mcpwm_init(&pwm_data);
// 启用PWM通道
mcpwm_open(pwm_ch0);
}
// 设置PWM占空比 (脉宽范围: 500us-2.5ms)
void pwm_test_set_pulse_width_us(u32 pulse_width_us)
{
u16 duty;
// 限制脉宽范围: 500us - 2500us
if (pulse_width_us < 500) {
pulse_width_us = 500;
} else if (pulse_width_us > 2500) {
pulse_width_us = 2500;
}
// 计算占空比: (脉宽/周期) * 10000
// 周期20ms = 20000us
duty = (pulse_width_us * 10000) / 20000;
// 设置占空比
mcpwm_set_duty(pwm_ch0, duty);
}
// 测试函数: 从最小脉宽到最大脉宽循环变化
void pwm_test_sweep(void)
{
u32 pulse_width;
pwm_test_set_pulse_width_us(500);
mdelay(1000);
pwm_test_set_pulse_width_us(2500);
mdelay(50);
}
// 主测试函数
void pwm_test_main(void)
{
// 初始化PWM
pwm_test_init();
// 设置最小脉宽500us
pwm_test_set_pulse_width_us(500);
// 运行脉宽扫描测试
while (1) {
pwm_test_sweep();
os_time_dly(100);
}
}

View File

@ -279,26 +279,26 @@ void contol_key_task(void){
control_key_init(); //遥感按键初始化
while(1){
// extern u16 get_vbat_level(void);
// vbat_value = get_vbat_level(); //当前电量
// control_key_get_value(&Xout_adc, &Yout_adc, &key1_state, NULL); //遥感值
// ble_data_buff[4] = (u8)(Yout_adc & 0xFF);
// ble_data_buff[5] = (u8)((Yout_adc >> 8) & 0xFF);
extern u16 get_vbat_level(void);
vbat_value = get_vbat_level(); //当前电量
control_key_get_value(&Xout_adc, &Yout_adc, &key1_state, NULL); //遥感值
ble_data_buff[4] = (u8)(Yout_adc & 0xFF);
ble_data_buff[5] = (u8)((Yout_adc >> 8) & 0xFF);
// ble_data_buff[6] = (u8)(Xout_adc & 0xFF);
// ble_data_buff[7] = (u8)((Xout_adc >> 8) & 0xFF);
ble_data_buff[6] = (u8)(Xout_adc & 0xFF);
ble_data_buff[7] = (u8)((Xout_adc >> 8) & 0xFF);
// ble_data_buff[8] = key1_state;
// ble_data_buff[9] = 0x01;
ble_data_buff[8] = key1_state;
ble_data_buff[9] = 0x01;
// ble_data_buff[10] = get_vbat_percent();
ble_data_buff[10] = get_vbat_percent();
// ble_data_buff[11] = 0;
// for(int i = 0 ;i < 11; i++){
// ble_data_buff[11] += ble_data_buff[i];
// }
ble_data_buff[11] = 0;
for(int i = 0 ;i < 11; i++){
ble_data_buff[11] += ble_data_buff[i];
}
u8 test_buff[12] = {0xBE,0xBB,0x09,0x01,0x50,0x50,0x50,0x50,0x01,0x01,0x50,0x15};
// u8 test_buff[12] = {0xBE,0xBB,0x09,0x01,0x50,0x50,0x50,0x50,0x01,0x01,0x50,0x15};
g_send_data_to_ble_server(ble_data_buff, sizeof(ble_data_buff));
/*
1000
@ -485,7 +485,9 @@ void test_task(void){
void test_func_main(void){
#if TEST_FUNCTION == 1
os_task_create(test_task, NULL, 1, 1024, 128, "rfid_test");
// os_task_create(test_task, NULL, 1, 1024, 128, "rfid_test");
extern void pwm_test_main(void);
os_task_create(pwm_test_main, NULL, 1, 1024, 128, "pwm_test");
// os_task_create(contol_key_task, NULL, 1, 2048, 128, control_key_task_name);
#endif

View File

@ -139,5 +139,5 @@ void xtell_app_main()
extern void test_func_main(void);
// test_func_main();
test_func_main();
}

View File

@ -113,7 +113,7 @@ int lp_vad_mic_data_init(struct vad_mic_platform_data *mic_data)
if (vbg_trim != 0xf) {
data->power_data.acm_select = get_vad_vbg_trim();
}
lp_vad_mic_in_enable(mic_data);
// lp_vad_mic_in_enable(mic_data); //xtell mic
return 0;
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -10,7 +10,7 @@ copy ..\..\ota.bin .
copy ..\..\anc_coeff.bin .
copy ..\..\anc_gains.bin .
..\..\isd_download.exe ..\..\isd_config.ini -tonorflash -dev br28 -boot 0x120000 -div8 -wait 300 -uboot ..\..\uboot.boot -app ..\..\app.bin -res ..\..\cfg_tool.bin tone.cfg p11_code.bin ..\..\eq_cfg_hw.bin -uboot_compress -format all
..\..\isd_download.exe ..\..\isd_config.ini -tonorflash -dev br28 -boot 0x120000 -div8 -wait 300 -uboot ..\..\uboot.boot -app ..\..\app.bin -res ..\..\cfg_tool.bin tone.cfg p11_code.bin ..\..\eq_cfg_hw.bin -uboot_compress -format all -key 646-AC690X-7603.key
@REM..\..\isd_download.exe ..\..\isd_config.ini -tonorflash -dev br34 -boot 0x20000 -div8 -wait 300 -uboot ..\..\uboot.boot -app ..\..\app.bin ..\..\cfg_tool.bin -res tone.cfg kws_command.bin p11_code.bin -uboot_compress

File diff suppressed because one or more lines are too long

View File

@ -4664,10 +4664,6 @@ objs/cpu/br28/smart_voice/vad_mic.c.o
-r=objs/cpu/br28/smart_voice/vad_mic.c.o,free,l
-r=objs/cpu/br28/smart_voice/vad_mic.c.o,lp_vad_mic_test,pl
-r=objs/cpu/br28/smart_voice/vad_mic.c.o,vad_disable,pl
-r=objs/cpu/br28/smart_voice/vad_mic.c.o,gpio_set_direction,l
-r=objs/cpu/br28/smart_voice/vad_mic.c.o,gpio_set_die,l
-r=objs/cpu/br28/smart_voice/vad_mic.c.o,gpio_set_pull_up,l
-r=objs/cpu/br28/smart_voice/vad_mic.c.o,gpio_set_pull_down,l
-r=objs/cpu/br28/smart_voice/vad_mic.c.o,__local_irq_disable,l
-r=objs/cpu/br28/smart_voice/vad_mic.c.o,__local_irq_enable,l
-r=objs/cpu/br28/smart_voice/vad_mic.c.o,lp_vad,pl
@ -5229,6 +5225,16 @@ objs/apps/earphone/xtell_remote_control/nvs/nvs.c.o
-r=objs/apps/earphone/xtell_remote_control/nvs/nvs.c.o,nvs_test_factory_info,pl
-r=objs/apps/earphone/xtell_remote_control/nvs/nvs.c.o,os_time_dly,l
-r=objs/apps/earphone/xtell_remote_control/nvs/nvs.c.o,puts,l
objs/apps/earphone/xtell_remote_control/pwm_test.c.o
-r=objs/apps/earphone/xtell_remote_control/pwm_test.c.o,pwm_test_init,pl
-r=objs/apps/earphone/xtell_remote_control/pwm_test.c.o,mcpwm_init,l
-r=objs/apps/earphone/xtell_remote_control/pwm_test.c.o,mcpwm_open,l
-r=objs/apps/earphone/xtell_remote_control/pwm_test.c.o,pwm_test_set_pulse_width_us,pl
-r=objs/apps/earphone/xtell_remote_control/pwm_test.c.o,mcpwm_set_duty,l
-r=objs/apps/earphone/xtell_remote_control/pwm_test.c.o,pwm_test_sweep,pl
-r=objs/apps/earphone/xtell_remote_control/pwm_test.c.o,mdelay,l
-r=objs/apps/earphone/xtell_remote_control/pwm_test.c.o,pwm_test_main,pl
-r=objs/apps/earphone/xtell_remote_control/pwm_test.c.o,os_time_dly,l
objs/apps/earphone/xtell_remote_control/RFID/reader/CPU_CARD.c.o
-r=objs/apps/earphone/xtell_remote_control/RFID/reader/CPU_CARD.c.o,CPU_CARD_EVENT,pl
-r=objs/apps/earphone/xtell_remote_control/RFID/reader/CPU_CARD.c.o,CPU_Rats,pl
@ -5384,6 +5390,8 @@ objs/apps/earphone/xtell_remote_control/task_func.c.o
-r=objs/apps/earphone/xtell_remote_control/task_func.c.o,adc_get_value,l
-r=objs/apps/earphone/xtell_remote_control/task_func.c.o,gpio_read,l
-r=objs/apps/earphone/xtell_remote_control/task_func.c.o,contol_key_task,pl
-r=objs/apps/earphone/xtell_remote_control/task_func.c.o,get_vbat_level,l
-r=objs/apps/earphone/xtell_remote_control/task_func.c.o,get_vbat_percent,l
-r=objs/apps/earphone/xtell_remote_control/task_func.c.o,g_send_data_to_ble_server,l
-r=objs/apps/earphone/xtell_remote_control/task_func.c.o,os_time_dly,l
-r=objs/apps/earphone/xtell_remote_control/task_func.c.o,create_key_detect_thread,pl
@ -5403,6 +5411,7 @@ objs/apps/earphone/xtell_remote_control/task_func.c.o
-r=objs/apps/earphone/xtell_remote_control/task_func.c.o,GetReg,l
-r=objs/apps/earphone/xtell_remote_control/task_func.c.o,TYPE_V_EVENT,l
-r=objs/apps/earphone/xtell_remote_control/task_func.c.o,test_func_main,pl
-r=objs/apps/earphone/xtell_remote_control/task_func.c.o,pwm_test_main,l
-r=objs/apps/earphone/xtell_remote_control/task_func.c.o,puts,l
objs/apps/earphone/xtell_remote_control/xtell_app_main.c.o
-r=objs/apps/earphone/xtell_remote_control/xtell_app_main.c.o,create_process,pl
@ -5420,6 +5429,7 @@ objs/apps/earphone/xtell_remote_control/xtell_app_main.c.o
-r=objs/apps/earphone/xtell_remote_control/xtell_app_main.c.o,start_app,l
-r=objs/apps/earphone/xtell_remote_control/xtell_app_main.c.o,check_power_on_voltage,l
-r=objs/apps/earphone/xtell_remote_control/xtell_app_main.c.o,rcsp_adv_fill_mac_addr,l
-r=objs/apps/earphone/xtell_remote_control/xtell_app_main.c.o,test_func_main,l
-r=objs/apps/earphone/xtell_remote_control/xtell_app_main.c.o,cpu_reset_by_soft,l
-r=objs/apps/earphone/xtell_remote_control/xtell_app_main.c.o,xt_bt_new_name,pl
-r=objs/apps/earphone/xtell_remote_control/xtell_app_main.c.o,app_var,l