TUYA_ADC_CONTINUOUS 模式下 BK7231N & TuyaOs 的 adc 采样频率 samp_rate 大概是多少
Posted: 2023年 Nov 9日 17:58
tuyaos sdk 版本是 3.7.7
由于目前项目需要对 50HZ的余弦波进行采样,BK7231N 配置为 TUYA_ADC_CONTINUOUS模式 根据 tkl_adc_init 函数的源码如下, adc_desc.samp_rate = 0x20 是不是说明采样频率是 32HZ呢?
Code: Select all
adc_desc.data_buff_size = cfg->conv_cnt;
adc_desc.pre_div = 8;
adc_desc.samp_rate = 0x20; // bk advise not to change
adc_desc.p_Int_Handler = saradc_disable;
但是根据测试,不断调用tkl_adc_read_single_channel 读取 余弦波 的数据看又不是 32HZ,请问TUYA_ADC_CONTINUOUS 模式下不断调用 tkl_adc_read_single_channel 其 adc 的采样率是多少??
我的代码如下:
Code: Select all
#define ADC_CHANNEL 2
#define ADC_COUNTS (252)
STATIC TUYA_ADC_BASE_CFG_T sg_adc_cfg = {
.ch_list.data = 1<<ADC_CHANNEL,
.ch_nums = 1, //adc Number of channel lists
.width = 12,
.mode = TUYA_ADC_CONTINUOUS,
.type = TUYA_ADC_INNER_SAMPLE_VOL,
.conv_cnt = ADC_COUNTS, //
// .freq = 4, // 没卵用
};
VOID_T example_adc(){
OPERATE_RET rt = OPRT_OK;
INT32_T adc_value[ADC_COUNTS + 68] = {0};
/* ADC 0 channel 2 init */
TAL_PR_DEBUG("ADC init");
TUYA_CALL_ERR_GOTO(tkl_adc_init(TUYA_ADC_NUM_0, &sg_adc_cfg), __EXIT);
TAL_PR_DEBUG("ADC init end, try read");
// TUYA_CALL_ERR_LOG(tkl_adc_read_single_channel(TUYA_ADC_NUM_0, ADC_CHANNEL, &adc_value));
while(1){
memset(adc_value, 0, ADC_COUNTS + 64);
// TUYA_CALL_ERR_LOG(tkl_adc_read_data(TUYA_ADC_NUM_0, adc_value, ADC_COUNTS));
TUYA_CALL_ERR_LOG(tkl_adc_read_single_channel(TUYA_ADC_NUM_0, ADC_CHANNEL, adc_value));
TAL_PR_DEBUG("ADC read end.");
for(int i=0; i < ADC_COUNTS; i++){
TAL_PR_DEBUG("ADC%d value = %d", TUYA_ADC_NUM_0, adc_value[i]);
}
}
TUYA_CALL_ERR_LOG(tkl_adc_deinit(TUYA_ADC_NUM_0));
__EXIT:
return;
}