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

关于CCS6.0与TMS32F38335的问题

如下这代码   分别直接下载在外部RAM仿真和下载到FLASH后复制到外部RAM运行  出现 以下问题

/*=====================================================================================
File name:        DWIN_USART_HMI.C
Description:
=====================================================================================*/
#include "DSP2833x_Device.h"
#include "DSP2833x_Examples.h"
#include "DSP2833x_GlobalPrototypes.h"
#include "IQmathLib.h"
void DWIN_USART_HMI(void);
void UART_Send_Start(void);
void UART_Send_dwin(float32 val,int16 address );
void motor_run(void );
void motor_stop(void );
extern void dwin_Oscilloscope(float32 val,int16 address );
extern void Return_instruction(void );
extern void Page_number8 (void);
void Page_number8 (void);
extern void UART_Send_dwin(float32 val,int16 address );
extern void UART_Send_Start(void);
void dwin_Oscilloscope(float32 val,int16 address );
/*—————————————————————————–
input
—————————————————————————–*/
/*—————————————————————————–
data
—————————————————————————–*/
extern float32 SpeedRpm;
extern float32 theta_elec;      // Output: Motor Electrical angle
extern float32 theta_mech;      // Output: Motor Mechanical Angle
/*————————-电流模拟变量———————–*/
extern float32  La;  //输出A相电流   DMABuf1[3]
extern float32  Lb;  //输出B相电流   DMABuf1[4]
extern float32  Lc;  //输出C相电流   DMABuf1[1]
/*————————-电压模拟变量———————–*/
extern float32  Ua;  //输出A相电压   DMABuf1[7]
extern float32  Ub;  //输出B相电压   DMABuf1[5]
extern float32  Uc;  //输出C相电压   DMABuf1[6]
/*————————-频率———————–*/
extern float32    Outputfre;
/*—————————————————————————–
output
—————————————————————————–*/
extern char  SCIBTXBuf[8];
extern char  SCIBRXBuf[8];
extern char  SCICTXBuf[8];
extern char  SCICRXBuf[8];
/*—————————————————————————–
internal
—————————————————————————–*/
extern int16  Timer0IntCount;
Uint16 address_number = 0;
Uint16 DADT_number = 0;
Uint16 Page_number = 1;
extern Uint16 Motor_switch ;
extern char  SCIRXBuf[8];
char  SCITXBuf[8];
/*—————————————————————————–
DWIN_USART_HMI.c
—————————————————————————–*/
void DWIN_USART_HMI(void)
{
  if(address_number >= DADT_number) address_number = 0;
  Return_instruction();
  Page_number8 ();
  if(Page_number == 1)    //Home Page
  {
   if(Motor_switch  == 1)
   {
    DADT_number = 5;
    if(Timer0IntCount == 1&&address_number == 0)motor_run();
    if(Timer0IntCount == 1&&address_number == 1)UART_Send_dwin(SpeedRpm,0x1110);
    if(Timer0IntCount == 1&&address_number == 2)UART_Send_dwin(Outputfre,0x1010);
    if(Timer0IntCount == 1&&address_number == 3)UART_Send_dwin(0,0×1140);//Motor_switch
    if(Timer0IntCount == 1&&address_number == 4)UART_Send_dwin(1,0×1141);//Motor_switch
   }
   if(Motor_switch  == 0)
    {
    DADT_number = 5;
    if(Timer0IntCount == 1&&address_number == 0)motor_stop();
    if(Timer0IntCount == 1&&address_number == 1)UART_Send_dwin(0,0×1110);
    if(Timer0IntCount == 1&&address_number == 2)UART_Send_dwin(0,0×1010);
    if(Timer0IntCount == 1&&address_number == 3)UART_Send_dwin(1,0×1140);//Motor_switch
    if(Timer0IntCount == 1&&address_number == 4)UART_Send_dwin(0,0×1141);//Motor_switch
    }
  }
  if(Page_number == 2)  //Voltage page
  {
   DADT_number = 3;
   if(Timer0IntCount == 1&&address_number == 0)UART_Send_dwin(Ua,0x1190);
   if(Timer0IntCount == 1&&address_number == 1)UART_Send_dwin(Ub,0x11A0);
   if(Timer0IntCount == 1&&address_number == 2)UART_Send_dwin(Uc,0x11B0);
  }
  if(Page_number == 3)  //Current page
  {
   DADT_number = 3;
   if(Timer0IntCount == 1&&address_number == 0)UART_Send_dwin(La,0x129C);
   if(Timer0IntCount == 1&&address_number == 1)UART_Send_dwin(Lb,0x12AC);
   if(Timer0IntCount == 1&&address_number == 2)UART_Send_dwin(Lc,0x12BC);
  }
  if(Page_number == 4)  //Angular velocity page
  {
   DADT_number = 3;
   if(Timer0IntCount == 1&&address_number == 0)UART_Send_dwin(theta_mech,0x13C0);
   if(Timer0IntCount == 1&&address_number == 1)UART_Send_dwin(theta_elec,0x13D0);
   if(Timer0IntCount == 1&&address_number == 2)UART_Send_dwin(SpeedRpm,0x13E0);
  }
  if(Page_number == 5)  //Torque page
  {
   DADT_number = 3;
   if(Timer0IntCount == 1&&address_number == 0)UART_Send_dwin(theta_mech,0x14D0);
   if(Timer0IntCount == 1&&address_number == 1)UART_Send_dwin(theta_elec,0x14E0);
   if(Timer0IntCount == 1&&address_number == 2)UART_Send_dwin(SpeedRpm,0x14F0);
  }
  if(Page_number == 6)  //Flux linkage page
  {
   DADT_number = 3;
   if(Timer0IntCount == 1&&address_number == 0)UART_Send_dwin(theta_mech,0x15DD);
   if(Timer0IntCount == 1&&address_number == 1)UART_Send_dwin(theta_elec,0x15ED);
   if(Timer0IntCount == 1&&address_number == 2)UART_Send_dwin(SpeedRpm,0x15FD);
  }
  if(Page_number == 7)  //Output setting page
  {
   DADT_number = 5;
   if(Timer0IntCount == 1&&address_number == 0)UART_Send_dwin(theta_mech,0x1710);
   if(Timer0IntCount == 1&&address_number == 1)UART_Send_dwin(theta_elec,0x1720);
   if(Timer0IntCount == 1&&address_number == 2)UART_Send_dwin(SpeedRpm,0x1730);
   if(Timer0IntCount == 1&&address_number == 3)UART_Send_dwin(theta_mech,0x1740);
   if(Timer0IntCount == 1&&address_number == 4)UART_Send_dwin(theta_mech,0x1750);
  }
/*
  if(Page_number == 8)  //Output setting page
  {
   DADT_number = 6;
   if(Timer0IntCount == 1&&address_number == 0)UART_Send_dwin(theta_mech,0x1835);
   if(Timer0IntCount == 1&&address_number == 1)UART_Send_dwin(theta_elec,0x1845);
   if(Timer0IntCount == 1&&address_number == 2)UART_Send_dwin(SpeedRpm,0x1855);
   if(Timer0IntCount == 1&&address_number == 3)UART_Send_dwin(theta_mech,0x1865);
   if(Timer0IntCount == 1&&address_number == 4)UART_Send_dwin(theta_mech,0x1875);
   if(Timer0IntCount == 1&&address_number == 5)UART_Send_dwin(theta_mech,0x1885);
  }
*/
}
/*—————————————————————————–
UART_Send_Start.c
—————————————————————————–*/
void UART_Send_Start(void)
{
    Uint16 K=0;
    for(K=0;K<8;K++)
    {
     SCIBTXBuf[K] = SCITXBuf[K];
     SCICTXBuf[K] = SCITXBuf[K];
    }
 ScibRegs.SCIFFTX.bit.TXFFINTCLR = 1;
 ScicRegs.SCIFFTX.bit.TXFFINTCLR = 1;
 Timer0IntCount = 0;
  address_number++;
}
/*—————————————————————————–
UART_Send_dwin.c
—————————————————————————–*/
void UART_Send_dwin(float32 val,int16 address )
{
       Uint16 temp=0,j;
       temp =  (int32) _IQtoF(_IQmpy(_IQ(val),_IQ(10)));
       for(j=0;j<8;j++)  {SCITXBuf[j] = 0;}
       SCITXBuf[0] = 0x5A;
       SCITXBuf[1] = 0xA5;
       SCITXBuf[2] = 0x05;
       SCITXBuf[3] = 0x82;
       SCITXBuf[4] = address>>8;
       SCITXBuf[5] = address;
       SCITXBuf[6] = temp>>8 ;
       SCITXBuf[7] = temp;
       UART_Send_Start();
}
void motor_run(void )
{
       SCITXBuf[0] = 0x5A;
       SCITXBuf[1] = 0xA5;
       SCITXBuf[2] = 0x05;
       SCITXBuf[3] = 0x82;
       SCITXBuf[4] = 0x10;
       SCITXBuf[5] = 0x00;
       SCITXBuf[6] = 0x00 ;
       SCITXBuf[7] = 0x01;
       UART_Send_Start();
}
void motor_stop(void )
{
       SCITXBuf[0] = 0x5A;
       SCITXBuf[1] = 0xA5;
       SCITXBuf[2] = 0x05;
       SCITXBuf[3] = 0x82;
       SCITXBuf[4] = 0x10;
       SCITXBuf[5] = 0x00;
       SCITXBuf[6] = 0x00 ;
       SCITXBuf[7] = 0x00;
       UART_Send_Start();
}
这个C文件 用CCS6.0编译通过   仿真或下载后  运行就会进非法中断
若随便屏蔽5-6行后  仿真或下载运行都恢复正常
屏蔽
       SCITXBuf[1] = 0xA5;
       SCITXBuf[2] = 0x05;
       SCITXBuf[3] = 0x82;
       SCITXBuf[4] = 0x10;
       SCITXBuf[5] = 0x00;
       SCITXBuf[6] = 0x00 ;
       SCITXBuf[7] = 0x00;
或屏蔽
   if(Timer0IntCount == 1&&address_number == 0)UART_Send_dwin(theta_mech,0x1835);
   if(Timer0IntCount == 1&&address_number == 1)UART_Send_dwin(theta_elec,0x1845);
   if(Timer0IntCount == 1&&address_number == 2)UART_Send_dwin(SpeedRpm,0x1855);
   if(Timer0IntCount == 1&&address_number == 3)UART_Send_dwin(theta_mech,0x1865);
   if(Timer0IntCount == 1&&address_number == 4)UART_Send_dwin(theta_mech,0x1875);
   if(Timer0IntCount == 1&&address_number == 5)UART_Send_dwin(theta_mech,0x1885);
 仿真或下载运行都恢复正常
或者将屏蔽的代码拆分到新的C文件中   则全部运行正常
之前也碰到一样的问题    通过拆分几个C文件后都正常运行

Johnson Chen1:

有没有试过其它版本编译器是否有同样问题?是否有调试看一下运行到哪条指令后进入非法中断?

赞(0)
未经允许不得转载:TI中文支持网 » 关于CCS6.0与TMS32F38335的问题
分享到: 更多 (0)