- 2024-09-03
-
回复了主题帖:
关于DSP28335外扩SRAM写数据后数据跳变的问题及SRAM赋值问题
wangerxian 发表于 2024-6-26 20:31
大概率是SRAM通信时许的问题。
抱歉,之前问题这个一直搁置了。以下是zone7的初始化,请问这个时序存在问题嘛?
/*
* init_zone7.c
*
* Created on: 2024年6月11日
* Author: Saturday
*/
#include <APP/xint_zone67/init_zone67.h>
void init_zone7(void)
{
EALLOW;
// Make sure the XINTF clock is enabled
SysCtrlRegs.PCLKCR3.bit.XINTFENCLK = 1;
EDIS;
// Configure the GPIO for XINTF with a 16-bit data bus
// This function is in DSP2833x_Xintf.c
InitXintf16Gpio();
// All Zones---------------------------------
// Timing for all zones based on XTIMCLK = SYSCLKOUT
EALLOW;
XintfRegs.XINTCNF2.bit.XTIMCLK = 0;
// Buffer up to 3 writes
XintfRegs.XINTCNF2.bit.WRBUFF = 3;
// XCLKOUT is enabled
XintfRegs.XINTCNF2.bit.CLKOFF = 0;
// XCLKOUT = XTIMCLK
XintfRegs.XINTCNF2.bit.CLKMODE = 0;
// Zone 7------------------------------------
// When using ready, ACTIVE must be 1 or greater
// Lead must always be 1 or greater
// Zone write timing
XintfRegs.XTIMING7.bit.XWRLEAD = 3;
XintfRegs.XTIMING7.bit.XWRACTIVE = 7;
XintfRegs.XTIMING7.bit.XWRTRAIL = 3;
// Zone read timing
XintfRegs.XTIMING7.bit.XRDLEAD = 3;
XintfRegs.XTIMING7.bit.XRDACTIVE = 7;
XintfRegs.XTIMING7.bit.XRDTRAIL = 3;
// don't double all Zone read/write lead/active/trail timing
XintfRegs.XTIMING7.bit.X2TIMING = 0;
// Zone will not sample XREADY signal
XintfRegs.XTIMING7.bit.USEREADY = 0;
XintfRegs.XTIMING7.bit.READYMODE = 0;
// 1,1 = x16 data bus
// 0,1 = x32 data bus
// other values are reserved
XintfRegs.XTIMING7.bit.XSIZE = 3;
EDIS;
//Force a pipeline flush to ensure that the write to
//the last register configured occurs before returning.
asm(" RPT #7 || NOP");
}
- 2024-09-02
-
发表了主题帖:
TMS320F28335 添加了一句程序后,编译没有问题,但ILLEGAL_ISR报错
在初始化阶段,我的程序需要读取文件中的数据,因此添加了一条“fscanf(p1, "%f", &ry[i]); ”程序。
在未添加之前,程序可以正常运行;添加之后,编译没有问题,但是运行时程序就会跳转到ILLEGAL_ISR报错。通过设置断点,发现跳转报错前执行的最后一条指令是void InitSpiaGpio()里的EALLOW。如果将fscanf这两句程序注释掉,那么程序正常运行。下面贴上初始化阶段的程序。
/*
* INIT.c
*
* Created on: 2023年5月29日
* Author: gy
*/
#include "main.h"
void SYSTERM_INIT()
{
InitSysCtrl();
//初始化PIE控制寄存器和PIE中断向量表
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
LED_Init();
DAC8563_Init();
EQEP1_Init();
init_zone67();
//// -------------读取u_ff数据------------
int i=0;
FILE *p1 = fopen("C:\\Users\\Saturday\\Desktop\\data_4000\\ry_init.dat", "r"); //1.dat文件放在.c文件所在的文件夹中
FILE *p2 = fopen("C:\\Users\\Saturday\\Desktop\\data_4000\\uff_init.dat", "r"); //1.dat文件放在.c文件所在的文件夹中
// FILE *p1 = fopen("C:\\Users\\Saturday\\Desktop\\data_4000\\ry_4000_1v1.dat", "r"); //1.dat文件放在.c文件所在的文件夹中
// FILE *p2 = fopen("C:\\Users\\Saturday\\Desktop\\data_4000\\uff_4000_1v1.dat", "r"); //1.dat文件放在.c文件所在的文件夹中
if (p1==NULL) //检测是否成功打开
printf("Open failed\n");
if (p2==NULL) //检测是否成功打开
printf("Open failed\n");
for (i = 0; i<20000; i++)
{
fscanf(p1, "%f", &ry[i]); //读入1.dat数据给数组c
fscanf(p2, "%f", &u_ff[i]);
if(i%1000==0){
printf("%f\t%d\n", u_ff[i],i);}
}
fclose(p1);//释放指针
fclose(p2);//释放指针
printf("load memory over");
////---------------------------------------------
//
//-------------------开机复位程序-----------------------
while(GpioDataRegs.GPADAT.bit.GPIO12 == 1){ //
Dac8563_reg_write(0x1F,31000); //第三个参数为复位时的电压 设置的小一些
SET_SYNC;
DELAY_US(1);
// if(GpioDataRegs.GPADAT.bit.GPIO12 == 0) break;
}
if(GpioDataRegs.GPADAT.bit.GPIO12 == 0){
Dac8563_reg_write(0x1F,33500); // 往正方向走一点,使得限位开关变为未触发状态
SET_SYNC;
DELAY_US(1);
DELAY_US(3000000); //延时1s
}
//
Dac8563_reg_write(0x1F,32768);
SET_SYNC;
DELAY_US(1);
DELAY_US(2000000); //延时2s
// --------------------------
//------------------------光栅尺计数清零-------------------------
EALLOW; // This is needed to write to EALLOW protected registers
EQep1Regs.QPOSCNT = 0;
EDIS;
//-----------------------初始换定时器和串口-------------------------
// TIM1_Init(150,200);
UARTb_Init(230400);
TIM0_Init(150,200);
}
在网上搜索了一些关于此问题的解决方案:
1.晶振出现问题;换了一个28335开发板,问题仍然存在,排除晶振问题。
2.CMD配置 堆栈.stack分配空间太小;,但memory allocation中显示是够用的。下面是CMD配置文件。
MEMORY
{
PAGE 0 :
/* BEGIN is used for the "boot to SARAM" bootloader mode */
BEGIN : origin = 0x000000, length = 0x000002 /* Boot to M0 will go here */
RAMM0 : origin = 0x000050, length = 0x0003B0
RAML0L1L2 : origin = 0x008000, length = 0x005000
RAML3 : origin = 0x00D000, length = 0x001000
CSM_RSVD : origin = 0x33FF80, length = 0x000076 /* Part of FLASHA. Program with all 0x0000 when CSM is in use. */
CSM_PWL : origin = 0x33FFF8, length = 0x000008 /* Part of FLASHA. CSM password locations in FLASHA */
ADC_CAL : origin = 0x380080, length = 0x000009
RESET : origin = 0x3FFFC0, length = 0x000002
IQTABLES : origin = 0x3FE000, length = 0x000b50
IQTABLES2 : origin = 0x3FEB50, length = 0x00008c
FPUTABLES : origin = 0x3FEBDC, length = 0x0006A0
BOOTROM : origin = 0x3FF27C, length = 0x000D44
PAGE 1 :
/* BOOT_RSVD is used by the boot ROM for stack. */
/* This section is only reserved to keep the BOOT ROM from */
/* corrupting this area during the debug process */
BOOT_RSVD : origin = 0x000002, length = 0x00004E /* Part of M0, BOOT rom will use this for stack */
RAMM1 : origin = 0x000400, length = 0x000400 /* on-chip RAM block M1 */
RAML4 : origin = 0x00C000, length = 0x001000
RAML5 : origin = 0x00D000, length = 0x001000
RAML6 : origin = 0x00E000, length = 0x001000
RAML7 : origin = 0x00F000, length = 0x001000
ZONE7 : origin = 0x200000, length = 0x100000
}
SECTIONS
{
/* Setup for "boot to SARAM" mode:
The codestart section (found in DSP28_CodeStartBranch.asm)
re-directs execution to the start of user code. */
codestart : > BEGIN, PAGE = 0
ramfuncs : > RAML0L1L2, PAGE = 0
.text : > RAML0L1L2, PAGE = 0
.InitBoot : > RAML0L1L2, PAGE = 0
.cinit : > RAML0L1L2, PAGE = 0
.pinit : > RAML0L1L2, PAGE = 0
.switch : > RAML0L1L2, PAGE = 0
.cio : > RAML4, PAGE = 1
.sysmem : > RAML4, PAGE = 1
.stack : > RAML4, PAGE = 1
.ebss : > RAML4, PAGE = 1
.econst : > RAML5, PAGE = 1
.esysmem : > RAMM1, PAGE = 1
IQmath : > RAML0L1L2, PAGE = 0
IQmathTables : > IQTABLES, PAGE = 0, TYPE = NOLOAD
FPUmathTables : > FPUTABLES, PAGE = 0, TYPE = NOLOAD
DMARAML4 : > RAML4, PAGE = 1
DMARAML5 : > RAML5, PAGE = 1
DMARAML6 : > RAML6, PAGE = 1
DMARAML7 : > RAML7, PAGE = 1
ZONE7DATA : > ZONE7, PAGE = 1
.reset : > RESET, PAGE = 0, TYPE = DSECT /* not used */
csm_rsvd : > CSM_RSVD PAGE = 0, TYPE = DSECT /* not used for SARAM examples */
csmpasswds : > CSM_PWL PAGE = 0, TYPE = DSECT /* not used for SARAM examples */
/* Allocate ADC_cal function (pre-programmed by factory into TI reserved memory) */
.adc_cal : load = ADC_CAL, PAGE = 0, TYPE = NOLOAD
}
/*
//===========================================================================
// End of file.
//===========================================================================
*/
3.数组指针问题。由于我用到的数据量较大,使用了外扩SRAM,在CMD中也可以看到定义了ZONE7DATA空间。INIT.c文件中使用的两个数组通过以下方式定义的
#pragma DATA_SECTION(u_ff,"ZONE7DATA");
volatile float u_ff[30000] = {0.0};
#pragma DATA_SECTION(ry,"ZONE7DATA");
volatile float ry[30000] = {0.0};
这个问题困扰我很久了,实在找不到解决方案,希望看到的各位大佬伸出援手,非常感谢!!
- 2024-06-26
-
回复了主题帖:
关于DSP28335外扩SRAM写数据后数据跳变的问题及SRAM赋值问题
工程中还使用了串口、spi等,但已经排除其接口与SRAM地址线数据线的复用问题
-
发表了主题帖:
关于DSP28335外扩SRAM写数据后数据跳变的问题及SRAM赋值问题
我使用是是普中科技的28335开发板。因为要存储数组数据,所以外扩了SRAM。定义了ZONE7区域,并将数组变量指定存储到该区域。在定时器中断程序中给该变量赋值,但是在Expression中观察,赋值过后的变量值仍然会跳变,而且在memory browser中观察该值,好像并没有赋值成功。以下是相关程序及截图:
图一CpuTimer0.InterruptCount已经超过了数组的范围,然后y_out数据发生了跳变(黄色就代表发生了变化)。
图二在memory browser中观察y_out数据空间,但是并没有值被赋值进来?
另外就是,我写了给u_ff初始化赋值的语句,但是并没有赋值成功,见图三,这种怎么初始化赋值呢?
//=============================
// ----------- time.c----------------
#pragma DATA_SECTION(y_out,"ZONE7DATA");
volatile float y_out[80000] = {0.0};
#pragma DATA_SECTION(u_ff,"ZONE7DATA");
volatile float u_ff[80000] = {
{0},
{-5.48168582231433},
{-28.0960788724069},
{-33.2755709254560},
{-28.4364523855368}
};
interrupt void TIM0_IRQn(void){
//省略其他无关代码
y_out[CpuTimer0.InterruptCount] = Pos;
CpuTimer0.InterruptCount++;
}
//==============================
// --------------28335_RAM_lnk.cmd----------------
PAGE 1 :
ZONE7B : origin = 0x201000, length = 0x0F0000 /* XINTF zone 7 */
SECTIONS
ZONE7DATA : > ZONE7B, PAGE = 1
//==============================
// -------------init_zone7.c --------------------------
void init_zone67(void)
{
EALLOW;
// Make sure the XINTF clock is enabled
SysCtrlRegs.PCLKCR3.bit.XINTFENCLK = 1;
EDIS;
// Configure the GPIO for XINTF with a 16-bit data bus
// This function is in DSP2833x_Xintf.c
InitXintf16Gpio();
// All Zones---------------------------------
// Timing for all zones based on XTIMCLK = SYSCLKOUT
EALLOW;
XintfRegs.XINTCNF2.bit.XTIMCLK = 0;
// Buffer up to 3 writes
XintfRegs.XINTCNF2.bit.WRBUFF = 3;
// XCLKOUT is enabled
XintfRegs.XINTCNF2.bit.CLKOFF = 0;
// XCLKOUT = XTIMCLK
XintfRegs.XINTCNF2.bit.CLKMODE = 0;
XintfRegs.XTIMING7.bit.XWRLEAD = 3;
XintfRegs.XTIMING7.bit.XWRACTIVE = 7;
XintfRegs.XTIMING7.bit.XWRTRAIL = 3;
// Zone read timing
XintfRegs.XTIMING7.bit.XRDLEAD = 3;
XintfRegs.XTIMING7.bit.XRDACTIVE = 7;
XintfRegs.XTIMING7.bit.XRDTRAIL = 3;
// don't double all Zone read/write lead/active/trail timing
XintfRegs.XTIMING7.bit.X2TIMING = 1;
// Zone will not sample XREADY signal
XintfRegs.XTIMING7.bit.USEREADY = 1;
XintfRegs.XTIMING7.bit.READYMODE = 1;
// 1,1 = x16 data bus
// 0,1 = x32 data bus
// other values are reserved
XintfRegs.XTIMING7.bit.XSIZE = 3;
EDIS;
//Force a pipeline flush to ensure that the write to
//the last register configured occurs before returning.
asm(" RPT #7 || NOP");
}