TI中文支持网
TI专业的中文技术问题搜集分享网站

LAUNCHXL-CC1352R1: DAC输出正弦波时出现电平回退的情况

Part Number:LAUNCHXL-CC1352R1

#include <stdint.h>
#include <stddef.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
/* 驱动头文件 */
#include <ti/drivers/DAC.h>
#include <ti/drivers/Timer.h>
#include <ti/drivers/GPIO.h>
#include <ti/drivers/UART.h>
/* 驱动配置 */
#include "ti_drivers_config.h"

#define COUNT (128)
#define HALFCOUNT (COUNT/2)

DAC_Handle dacHandle;
UART_Handle uart;
UART_Params uartParams;
uint32_t sintable[COUNT] = {0x80,0x86,0x8c,0x92,0x98,0x9e,0xa5,0xaa,0xb0,0xb6,0xbc,0xc1,0xc6,0xcb,0xd0,0xd5,0xda,0xde,0xe2,0xe6,0xea,0xed,0xf0,0xf3,0xf5,0xf8,0xfa,0xfb,0xfd,0xfe,0xfe,0xff,0xff,0xff,0xfe,0xfe,0xfd,0xfb,0xfa,0xf8,0xf5,0xf3,0xf0,0xed,0xea,0xe6,0xe2,0xde,0xda,0xd5,0xd0,0xcb,0xc6,0xc1,0xbc,0xb6,0xb0,0xaa,0xa5,0x9e,0x98,0x92,0x8c,0x86,0x80,0x79,0x73,0x6d,0x67,0x61,0x5a,0x55,0x4f,0x49,0x43,0x3e,0x39,0x34,0x2f,0x2a,0x25,0x21,0x1d,0x19,0x15,0x12,0x0f,0x0c,0x0a,0x07,0x05,0x04,0x02,0x01,0x01,0x00,0x00,0x00,0x01,0x01,0x02,0x04,0x05,0x07,0x0a,0x0c,0x0f,0x12,0x15,0x19,0x1d,0x21,0x25,0x2a,0x2f,0x34,0x39,0x3e,0x43,0x49,0x4f,0x55,0x5a,0x61,0x67,0x6d,0x73,0x79};
uint16_t sin_count = 0;
uint16_t count = 0;
Timer_Handle timer0;
char str[30];

/**
\brief timerCallback
\note 无特殊说明
\see 无参考
\param 参数myHandle: 定时器句柄
\param 参数status: 定时器状态
\retval None
\warning 无警告
*/
void timerCallback(Timer_Handle myHandle, int_fast16_t status);

/**
\brief get_sintable
\note 无特殊说明
\see 无参考
\param 参数count: 生成样本的数量
\param 参数table: 存储生成样本的数组
\retval None
\warning 无警告
*/
void get_sintable(uint16_t count,uint32_t *table);

/**

\brief mainThread

\note 无特殊说明

\see 无参考

\param 参数arg0: 额外传递的参数

\retval None

\warning 无警告
*/
void *mainThread(void *arg0)
{Timer_Params params;DAC_Params dacParams;Timer_init();//GPIO_init();DAC_init();UART_init();//GPIO_setConfig(CONFIG_GPIO_0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);//GPIO_write(CONFIG_GPIO_0, CONFIG_GPIO_LED_ON);UART_Params_init(&uartParams);uartParams.writeDataMode = UART_DATA_BINARY;uartParams.readDataMode = UART_DATA_BINARY;uartParams.readReturnMode = UART_RETURN_FULL;uartParams.baudRate = 115200;uart = UART_open(CONFIG_UART_0, &uartParams);get_sintable(COUNT,sintable);DAC_Params_init(&dacParams);dacHandle = DAC_open(CONFIG_DAC_0, &dacParams);DAC_enable(dacHandle);Timer_Params_init(&params);params.period = 10000;params.periodUnits = Timer_PERIOD_US;params.timerMode = Timer_CONTINUOUS_CALLBACK;params.timerCallback = timerCallback;timer0 = Timer_open(CONFIG_TIMER_0, &params);Timer_start(timer0);while(1){}
}

void timerCallback(Timer_Handle myHandle, int_fast16_t status)
{
//if(sin_count < COUNT - 1 && sin_count != HALFCOUNT)
//{
//DAC_setCode(dacHandle, sintable[sin_count++]);
////sprintf(str,"%d\n",sintable[sin_count]);
//}
//else if(sin_count == HALFCOUNT)
//{
//sin_count += 15;
//DAC_setCode(dacHandle, sintable[sin_count++]);
//}
//else
//{
//DAC_setCode(dacHandle, sintable[sin_count]);
////sprintf(str,"%d\n",sintable[sin_count]);
//sin_count = 15;
//}
//if(sin_count < COUNT - 1)
//{
//DAC_setCode(dacHandle, sintable[sin_count++]);
//}
//else
//{
//DAC_setCode(dacHandle, sintable[sin_count]);
//sin_count = 0;
//}DAC_setCode(dacHandle, sintable[sin_count]);sin_count++;if(sin_count >= COUNT){sin_count = 0;}sprintf(str,"%d  %d\n", sin_count,sintable[sin_count]);UART_write(uart, str, strlen(str));
//UART_write(uart, str, strlen(str));
}


void get_sintable(uint16_t count,uint32_t *table)
{uint16_t i = 0;for(i = 1;i <= count;i++){double num = (1.0+sin(2.0*M_PI *(1.0*i/(count))))*128;table[i-1] = num ;
//if(i == HALFCOUNT)
//{
//sprintf(str,"-----------\n");
//UART_write(uart, str, strlen(str));
//}sprintf(str,"%d\n", table[i]);UART_write(uart, str, strlen(str));}
}

原始代码如上,在示波器上发现正负半周交界处会存在失真,多次优化波表后仍存在此情况,具体如下图:

然后逐步排查问题,通过串口打印数据进行调试,发现串口打印数据正常,但单片机实际输出电压却不与设定电压不吻合。

如下:

Yolande Wang:

?? ? 说:正负半周交界处会存在失真

您好,这种情况通常是由于信号处理或DAC问题引起的,时钟抖动可能会导致交界处的失真或者是时序和采样时间不正确。

,

Yolande Wang:

您的问题解决了吗,如果没有这边将继续为您跟进。

,

?? ?:

首先,感谢你的解答!那么遇到这种情况该怎么解决呢?目前遇到的问题是,DAC输出在特定的变化曲线下,发生了电平回退,造成了波形失真。

,

Yolande Wang:

已收到您的消息,我将咨询英文论坛的工程师,需要一些时间,有进展立即回复您!

,

?? ?:

好的,谢谢!

,

Yolande Wang:

不客气,请等候一下。

,

Yolande Wang:

您好,

以下是来自E2E的答复:

此错误已在我们较新的 SDK 版本中修复。我鼓励您升级您的 SDK,并亲自尝试一下。

您先试试,如果问题未解决,这边将继续为您跟进!

,

?? ?:

你好,请问是从哪个SDK版本开始修复的这个问题呢?

,

Yolande Wang:

您现在用的是哪一个版本呢,我们官方最新SDK版本是7.10.01.24,建议您用最新的版本;具体是哪个版本开始修复,我需要询问一下。

https://www.ti.com.cn/tool/cn/download/SIMPLELINK-LOWPOWER-F2-SDK

,

?? ?:

我目前使用的版本是5.20.0.52,还请你帮我询问一下,谢谢!

,

Yolande Wang:

您好,

以下是E2E的回复:

It has been fixed version 6.40, so about a year ago. Again, I recommend you to use the latest SDK if possible.

,

?? ?:

好的,非常感谢你的回复!我还想了解一下,那么在现有的5.20.0.52版本下,我们可以做出什么操作,从而使这种情况得到改善吗?

,

Yolande Wang:

明确您的需求,请等候一下。

,

Yolande Wang:

Hi,

Is there any reason to stay under 5.20.0.52?

You could download the latest SDK, and extract the following files:

DACCC26XX.Board.c.xdt
DACCC26XX.syscfg.js
DACCC26X2.c
DACCC26X2.h

And then copy them to your old SDK.

If you are to do this, I recommend you to track the changes in your SDK with the help of git.

Running the following command:

git init . && git add * && git commit -m "Original SDK"

prior to modifying the SDK will give you peace of mind.

Best regards,

Yolande

,

?? ?:

好的,感谢你的耐心解答!

,

Yolande Wang:

不客气,欢迎随时来论坛交流!

赞(0)
未经允许不得转载:TI中文支持网 » LAUNCHXL-CC1352R1: DAC输出正弦波时出现电平回退的情况
分享到: 更多 (0)