TI中文支持网
TI专业的中文技术问题咨询交流网站

TMS320F28377D: F28377的CLA使用汇编的例程。

TX dong阅读(8)

Part Number:TMS320F28377DOther Parts Discussed in Thread:C2000WARE

现在F28377的例程,关于CLA的都是C语言形式,我感觉CLA处理问题时,使用的指令很少,用汇编做出的程序,运行效率最高,

最近用到F28377的CLA,也算了本器件的第一次使用,请给个例程。

希望:

       1、CLA部分用汇编。

       2、烧写到ROM内。

谢谢大家!!

Yale Li:

所有的例程都在SDK中了:

C:\ti\c2000\C2000Ware_5_00_00_00\driverlib\f2837xd\examples\cpu1\cla

C:\ti\c2000\C2000Ware_5_00_00_00\device_support\f2837xd\examples\cpu1

TMS320F28335: SCIA、SCIB和SCIC同时运行

xiaofei wang阅读(8)

Part Number:TMS320F28335

请问TMS320F28335的SCIA、SCIB和SCIC三个模块工作是独立的吗,三个模块可以同时工作而互不干扰吧?

Yale Li:

是的

TMS320F28374S: CCS编译优化级别影响U32位指针类型变量取地址的问题。

文智 张阅读(6)

Part Number:TMS320F28374S

我在做源c文件代码封装为静态库文件.Lib时,遇到了指针类型变量在不同优化级别下,指针取值的地址不一致的问题。

实际现象: 

使用CCS8.2建立一个输出类型为executable类型的工程,编译器为18.1.1.LTS。在C文件 TEST.c 中,定义一个* unsigned long 类型的变量A (无符号32位指针),定义一个unsigned long 类型的变量B(无符号32位整型), 编译器使用1级优化。 

令这个这个指针指向地址为0x00014279。 对A进行取值操作将值赋值给B,观测到B中的数据为0x0001427A(高16位) 0x00014279(低16位)两个地址的值。

使用同样的C文件, 使用CCS8.2建立一个输出类型为静态库的工程,编译器为18.1.1.LTS。编译器使用0级优化,编译之后得到。lib文件。将这个LIb文件替换掉上面工程中的TEST.C文件,

观测到观测到B中的数据为0x00014279(高16位) 0x00014278(低16位)两个地址的值。

请问为什么会出现这样的现象?

Yale Li:

如果优化等级调整为相同的,结果如何呢?

文智 张 said:将这个LIb文件替换掉上面工程中的TEST.C文件

能再具体描述一下这里吗?

,

文智 张:

如果编译静态库文件时候的优化级别设置为1,再替换c文件源码,则与直接使用c文件源码编译的结果一样。

,

Yale Li:

我需要一些时间来看一下

TMS320F28335: MCBSP设置为SPI时,发送数据此寄存器McbspbRegs.SPCR2.bit.XRDY一直为0

orange阅读(14)

Part Number:TMS320F28335

程序运行时,一直在等待发送寄存器为空这里循环

Uint16 Mcbsp_SPI_Byte(Uint16 data)
{

    // 等待发送寄存器为空
    while(McbspbRegs.SPCR2.bit.XRDY != 1);
    // 向发送寄存器写入数据
    McbspbRegs.DXR1.all = data;

    // 等待接收就绪
    while(McbspbRegs.SPCR1.bit.RRDY != 1);
    return McbspbRegs.DRR1.all;

}

Yale Li:

请看一下相关寄存器的描述:

sprui07_TMS320x2833x, TMS320x2823x Technical Reference Manual第752页

TMS320F28335: EQEP. Z索引脉冲没有复位位置计数器

qw qw阅读(9)

Part Number:TMS320F28335

GPiO和eqep配置如下,外设只接A和Z信号,A信号脉宽20us,Z信号脉宽200us,都是负脉冲,配置索引模式,Z信号到的时候位置计数器没有清零,是什么原因?对DSP复位后,z信号又重新起作用了


Z信号索引脉冲到来没有复位位置计数器的时的状态:QFLG=0840,QEPSTS=00A8

索引信号到来复位位置计数器时的状态,QFLG=0C02,QEPSTS=00FB

Yale Li:

这个问题出现的概率有多大?

TMS320F280033: flash Entry Point

QADZ阅读(7)

Part Number:TMS320F280033Other Parts Discussed in Thread: C2000WARE

使用TMS320F280033,在CMD文件中设置BEGIN为0x88000,脱离仿真器无法运行。

一般的CMD文件都是设置BEGIN为0x80000,但是280033的FLASH地址是从0x88000开始的,这个该如何解决

Yale Li:

使用的是哪个版本的C2000ware?

,

QADZ:

是5.0.0.00

,

Yale Li:

CCS是什么版本?

,

QADZ:

CCS是11.2版本

,

Yale Li:

请使用最新版本的CCS试一下

TMS320F280039C: TMS320F280039C

vicki阅读(65)

Part Number:TMS320F280039C

280039烧录程序过程中,TCK信号一直是变频的吗

Yale Li:

是的,TCK就是JTAG的时钟信号

TMS320F28035: Problems in using the ADC function of TMS320F28035 to collect the power supply voltage

DSP入门学习阅读(8)

Part Number:TMS320F28035

There are some problems when using the TMS320F28035 chip:

Objective: To use the ADCINA1 passband of the TMS320F28035 chip (56-pin) for power supply voltage measurement

Tools: Already have TMS320F28035 chip (64 pin) ADCINA1 measure the power supply voltage code (after the test code is correct, can normally read 0-3.3V voltage value), the specific code is as follows:

First, the main.c code:

#include "DSP2803x_Device.h" // DSP2833x Headerfile Include File
#include "DSP2803x_Examples.h" // DSP2833x Examples Include Fi

#include "stdio.h"
#include "Battery.h"
#include "leds.h"
#include "Tim.h"
extern Uint16 RamfuncsLoadSize;
/******************************************************************************
*函数原型:		void main(void)
*函数功能:飞控主函数
*******************************************************************************/
void main(void)
{
	InitSysCtrl();
	DINT;
	InitPieCtrl();
	IER = 0x0000;
	IFR = 0x0000;
	InitPieVectTable();
	memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (Uint32)&RamfuncsLoadSize);
	LED_Init();// 初始化LED-
	BatteryCheckInit();// 初始化电池检测ADC-
	BatteryCheck();// 检测电池电压;软件触发ADC采集-
	Timer0_init();// 定时器0初始化,1ms周期中断-
	PieCtrlRegs.PIECTRL.bit.ENPIE = 1;
	EINT;
	ERTM;while(1)
	{

/* 电源电压检测及片上温度检测;信号灯提示(100ms为一个周期)*/	if(timer0Base.loop10HzCnt >= 1000)	{		timer0Base.loop10HzCnt=0;		BatteryCheck();// 电源电压监控TemperatureCheck();// 片上温度采集		//LEDFSM();// 信号灯提示LED1_TOGGLE;LED2_TOGGLE;	}
	}
}

Battery.c code

#include "Battery.h"

#include "stdio.h"

Bat_Typedef Battery;
int adcVal[2]={0};//ADC 采样结果
char adcISRFlag=0;//ADC 中断标识
int16 degC; //temperature in deg. C
interrupt void adc_isr(void);
/*******************************************************************************
* 函 数 名:void BatteryCheckInit(void)
* 函数功能:AD初始化;将模拟值输入到A1通道
*******************************************************************************/
void BatteryCheckInit(void)
{
	InitAdc();  // 初始化ADC对应的GPIO
	EALLOW;
	PieVectTable.ADCINT3 = &adc_isr;// AD中断函数映射
	EDIS;
	PieCtrlRegs.PIEIER10.bit.INTx3 = 1;//使能 PIE 的 INT10.3
	IER |= M_INT10;
	EALLOW;
	AdcRegs.ADCCTL2.bit.ADCNONOVERLAP = 1;  //不允许重叠采样
	AdcRegs.ADCCTL1.bit.TEMPCONV  = 1; 		//设置片上温度传感器
	FlashRegs.FOTPWAIT.bit.OTPWAIT = 1;//设置 flash OTP 等待状态为最小,以保证温度转换函数的性能
	EDIS;
	EALLOW;
	AdcRegs.ADCCTL1.bit.ADCREFSEL	= 0;//Internal Bandgap//内部带隙产生参考电压
	AdcRegs.ADCCTL1.bit.INTPULSEPOS	= 1;	//ADCINT1 trips 产生中断脉冲, 1 个周期后 ADC 锁存到结果寄存器。
	AdcRegs.INTSEL3N4.bit.INT3E= 1;	//Enabled ADCINT3
	AdcRegs.INTSEL3N4.bit.INT3CONT  = 0;	//禁止连续转换模,single conversion mode 直到 ADCINTx 标志 (在 ADCINTFLG 寄存器) 由用户清除, 无进一步的 ADCINTx脉冲产生。
	AdcRegs.INTSEL3N4.bit.INT3SEL	= 1;	//创建EOC1,EOC1 为 ADCINTx 的触发。
	AdcRegs.ADCSOC0CTL.bit.TRIGSEL 	= 0x00; //软件触发,没有 ADCINT 触发 SOCx。 TRIGSEL 位域确定 SOCx 触发。
	AdcRegs.ADCSOC1CTL.bit.TRIGSEL 	= 0x00; //软件触发,没有 ADCINT 触发 SOCx。 TRIGSEL 位域确定 SOCx 触发。
	AdcRegs.ADCSOC0CTL.bit.CHSEL 	= 5;	//片上温度采集,SOCx通道选择
	AdcRegs.ADCSOC1CTL.bit.CHSEL 	= 1;	//电源采集,SOCx 通道选择
	AdcRegs.ADCSOC0CTL.bit.ACQPS 	= 6;	//设置窗口,SOCx 采样预定标, 为 SOCx 控制采样保持窗口, 最小值为6
	AdcRegs.ADCSOC1CTL.bit.ACQPS 	= 6;	//设置窗口,采样窗为7 个周期长 (6 + 1 时钟周期)
	EDIS;
	Battery.ADRef= 3.31;// 实际测量的MCU供电电压
	Battery.Bat_K= 1.0;// 电压校准系数
	Battery.overDischargeCnt = 0;
	Battery.Calisum = 0.0;// 电池的sum校准系数
	printf("\r\nADC(BATTERY) init...OK");
}

/*******************************************************************************
* 函 数 名:void BatteryCheckInit(void)
* 函数功能:AD 中断处理函数
*******************************************************************************/
interrupt void  adc_isr(void)
{
	EALLOW;
	PieCtrlRegs.PIEACK.all = PIEACK_GROUP10;//Acknowledge interrupt to PIE
	EDIS;
	AdcRegs.ADCINTFLGCLR.bit.ADCINT3 = 1;	//Clear ADCINT1 flag
	adcISRFlag = 1;
	adcVal[0]=AdcResult.ADCRESULT0; //温度
	adcVal[1]=AdcResult.ADCRESULT1; //电压
}

/*******************************************************************************
* 函 数 名:int GetBatteryAD(u8 ch)
* 函数功能:获取电池单次的ADC
*******************************************************************************/
int GetBatteryAD(u8 ch)
{
	AdcRegs.ADCSOCFRC1.all = 0X03; //软件触发AD 的 SOC0--SOC1采样
	if(adcISRFlag == 1)
	{
		adcISRFlag = 0;
	}
	return adcVal[ch];
}

/*******************************************************************************
* 函 数 名:int Get_Adc_Average(u8 ch,u8 times)
* 函数功能:获取A1通道的AD值
*******************************************************************************/
int Get_Adc_Average(u8 ch,u8 times)
{
	int temp_val=0;
	u8 t;
	for(t=0;t<times;t++)
	{
		temp_val+=(GetBatteryAD(ch));
	}
	return temp_val/times;
}

/*******************************************************************************
* 函 数 名:void TemperatureCheck(void)
* 函数功能:检测MCU温度
*******************************************************************************/
void TemperatureCheck(void)
{
	degC = GetTemperatureC(Get_Adc_Average(0,5));// 片上温度采样
}

/*******************************************************************************
* 函 数 名:void BatteryCheck(void)
* 函数功能:检测电池电压;过放报警和过放保护
*******************************************************************************/
void BatteryCheck(void)
{
	Battery.BatteryAD  = Get_Adc_Average(1,5);  // 滤波后的电压值
	//printf("\r\n滤波后的电压值:%d\n",Battery.BatteryAD);
	Battery.BatteryVal = (float)(Battery.Bat_K*((Battery.BatteryAD/4096.0)*Battery.ADRef))+Battery.Calisum;//实际电压值计算printf("\r\n实际电压值:%f\n",Battery.BatteryVal);

	if(1)
	{
		if(Battery.BatteryVal <= (BAT_OVERDIS_VAL + 0.03))
		{
			Battery.alarm=1;// 报警位
		}else{
			Battery.alarm=0;
		}

		if(Battery.BatteryVal <= BAT_OVERDIS_VAL)
		{
			Battery.overDischargeCnt++;// 过放保护计数
			if(Battery.overDischargeCnt > 3)
			{
			
			}
		}else
			{
				Battery.overDischargeCnt = 0;
			}
	}
	else
	{
		if(Battery.BatteryVal < BAT_ALARM_VAL) // 3.65V
		{
			Battery.alarm=1;// 报警位
		}else{
			Battery.alarm=0;
		}
	}
}

Battery.h code

#ifndef INC_BATTERY_H_
#define INC_BATTERY_H_

#include "DSP2803x_Device.h" // DSP2833x Headerfile Include File
#include "DSP2803x_Examples.h" // DSP2833x Examples Include Fi

#define uint8_t unsigned char
#define uint16_t unsigned short
#define uint32_t unsigned long
#define uint64_t unsigned long long
#define int8_t  signed char
#define int16_t signed short
#define int32_t signed long
#define int64_t signed long long

typedef int8_t s8;
typedef uint8_t u8;
typedef int16_t s16;
typedef uint16_t u16;
typedef int32_t s32;
typedef uint32_t u32;



extern int adcVal[];//ADC 采样结果
extern char adcISRFlag;//ADC 中断标识
extern int16 degC;

#define BAT_CHK_PRD500
#define BAT_ALARM_VAL3.65
#define BAT_OVERDIS_VAL 3.15

//电压信息结构体
typedef struct
{
float  ADRef;// AD参考源
float  Bat_K;// 计算电压值
charalarm;// 电池报警位
charchargeSta;// 充电状态
float  BatteryVal;// 电压
intBatteryAD;// 电压
intoverDischargeCnt;// 过放保护计数
float  Calisum;
}Bat_Typedef;
extern Bat_Typedef Battery;

/*函数声明*/
void BatteryCheckInit(void);
int Get_Adc_Average(u8 ch,u8 times);
int GetBatteryAD(u8 ch);
void TemperatureCheck(void);
void BatteryCheck(void);

#endif /* INC_BATTERY_H_ */

After my test, the code in TMS320F28035 (64 pin) can normally collect the power supply voltage through the ADCINA1 channel. Due to work requirements, now I need to switch to the chip TMS320F28035 (56-pin), which also needs to collect the power supply voltage. Using the same code and ADCINA1 channel, I failed to collect the real power supply voltage, and the collected result is displayed as about 0.0V. I have the following problems:

1. The corresponding pin of ADCINA1 of TMS320F28035 (56-pin) is 12, while the corresponding pin of ADCINA1 of (64-pin) is 14. Do I need to configure the pin (or GPIO) in ccs software?

2. The hardware schematic diagram I drew is as follows. It can be seen that the acquisition line of ADCINA1 is directly connected to the battery power line (full voltage 4.2v for 1s lithium battery). I did not use the voltage division circuit for voltage reduction, is it possible that the ADCINA1 interface has been burned out?

3. Run the program in the control board I drew with the above code, and the voltage value collected by the ADC has been changing around 0.055615v (maximum 0.1v). Does this mean that the ADCINA1 acquisition port is grounded?

4. If I place the ADC1 acquisition port behind the capacitor (as shown below), can I use it directly without adding other voltage divider circuits?

5. If the divider circuit must be used, how to draw the detailed schematic diagram of the divider ADC collection divider circuit?

Urgently need to solve, hope to get your reply as soon as possible,thanks!!!

Yale Li:

1. You need to re-route the ADCINA1 pin for 56pin device. It is achieved by modify the code.

2. Yes, this pin will be damaged very likely.

3. Do you mean that you think the circuit is damaged? That means the point ADC1 is shorted to the ground? You can power-off the circuit then check it.

4. It decided by the voltage range that this pin measured.

5. ADC front-end circuit is a large topic. The most simple way is using resistors to divide the voltage. Please refer the following links for further:

https://www.ti.com.cn/zh-cn/design-development/analog-circuits.html

zhcy094a_模拟工程师电路设计指导手册:数据转换器 (Rev. A)

spract6a_ADC Input Circuit Evaluation for C2000 MCUs (using TINA-TI simulation tool) (Rev. A)

Introduction to SAR ADC front-end component selection

,

DSP入门学习:

Hi Yale Li,

Thank you very much for answering my questions. I will carefully study the materials and tutorials you provided.

I have the following questions:

1.Which line of code in which file should I modify to correctly configure a 56pin ADCINA1 channel? (I looked up the code carefully and did not find where to configure a 56pin ADCINA1 channel)

2.What is the maximum voltage that the ADCINA1 channel of TMS320F28035RSHT(56pin) chip can input? (no divider circuit)

3."Do you mean that you think the circuit is damaged?"→Yes, I think my ADCINA1 channel has been burned out. I input about 5v voltage to the ADCINA1 channel (without partial voltage), but when the ADC collection code is correct, the measured voltage value is 0.0, so I suspect that the ADCINA1 channel has been burned out.

4.If I place the ADC1 acquisition port behind the capacitor (as shown below), can I use it directly without adding other voltage divider circuits?

Thank you again and look forward to your reply.

Andy

,

Yale Li:

1. My fault. It doesn't need. In C2000 device, the analog pin is discrete with the digital pin.

2. It is decided by which reference voltage you are using. Pls check the related part in datasheet:

https://www.ti.com/lit/ds/symlink/tms320f28035.pdf

3. You can use routine to check if the device has been damaged.

Which board are you using? TI's demo board? Whatever which board you are using, you need to discrete the external circuit from the ADC pin. The 5V voltage is not applicable on this pin.

4. No. It is same node.

,

DSP入门学习:

Dear Yale Li,

Thank you for your earnest reply, which is very helpful to me.

I now know that my mistake was on the ADCINA1 acquisition port, I should not have connected the acquisition port directly to the positive terminal of the 1S lithium battery without using the voltage divider circuit.

After carefully consulting the information you provided and your detailed answers, I modified my circuit schematic diagram (Figure 1). I think this schematic diagram is correct, and the power supply voltage of 1S lithium battery can be correctly collected.

Do you think it is feasible to modify the circuit in this way? Can I collect a voltage value of 4.2V?

If this circuit is feasible, I will start to submit PCB boards for production.

Looking forward to your reply. Thank you very much

Best wishes

Andy

,

Yale Li:

Yes. At least it provide the correct voltage.

TMS320F280049C: 280049 ADC 测量值不准

Fei Gao阅读(5)

Part Number:TMS320F280049COther Parts Discussed in Thread:REF35

您好:

ADC采样我使用内部3.3V参考电压,采样窗口设置为10.现在的采样值比实际值偏小5%左右,我使用两块不同的开发板测试结果都一样。

1.是不是因为内部参考电压不准?如果使用REF35芯片提供外部电压,采样值就会准吗?

2.如果采用外部3V参考电压,ADC输入电压为3V时对应4095?如果采用2.5V外部参考电压,ADC输入电压为2.5V时对应4095?

3.我需要对交流电压采样,如果采用2.5V作为外部参考电压,交流电压是不是可以和1.25V的基准电压进行比较,大于1.25V是正半周,小于1.25V是负半周?

Yale Li:

1. 内部基准的增益误差确实更大些:

2. 是的;

3. 可以。需要通过外部调理电路将偏置调到1.25V,幅值调到2.5V。

© 2023 TI中文支持网   网站地图 鲁ICP备2022002796号-1