我在expressions里观察程序中变量的值时,提示如图所示的错误,即“unexpected token”请问是什么原因?
另外,expressions里提示的发生错误的Line数也不对,请问该如何解决?
谢谢!
Andy Yin1:
您好,
我们试过都是可以没有问题,请将你跑的代码发上来看看,同时将你的测试过程说明一下,谢谢
andy lee1:
回复 Andy Yin1:
您好!
以下是DDR初始化程序DDRInit.c的代码,我是在Debug以后单步运行,然后在expressions里观察变量的值,整个单步运行的过程中指针变量boot_cfg_regs所指的结构体中的成员变量都分配了地址,并都能查看到值,而DDR_Regs所指的结构体中的变量成员都提示“unexpected token”的错误,请问会是什么原因?谢谢!
#include <stdio.h>
#include <csl_bootcfgAux.h>
#include "DDR_Init.h"
#include "common.h"
#include<cslr_emif4f.h>
CSL_Emif4fRegs *DDR_Regs = (CSL_Emif4fRegs *)CSL_DDR3_EMIF_CONFIG_REGS;//0x21000000
CSL_BootcfgRegs *boot_cfg_regs = (CSL_BootcfgRegs *)CSL_BOOT_CFG_REGS;//0x02620000
void Shannon_EVM_DDR_Init(float clock_MHz)
{
printf("configure DDR at %d MHz\n", (unsigned int)clock_MHz);
CSL_BootCfgUnlockKicker();
//配置SDRAM定时寄存器(SDTIM1~SDTIM3)
DDR_Regs->SDRAM_TIM_1 =//11077823
((unsigned int)(13.5*clock_MHz/1000.f-0.0001f)<<CSL_EMIF4F_SDRAM_TIM_1_REG_T_RP_SHIFT)|
((unsigned int)(13.5*clock_MHz/1000.f-0.0001f)<<CSL_EMIF4F_SDRAM_TIM_1_REG_T_RCD_SHIFT)|
((unsigned int)(6*clock_MHz/1000.f-0.0001f)<<CSL_EMIF4F_SDRAM_TIM_1_REG_T_WR_SHIFT)|
((unsigned int)(36*clock_MHz/1000.f-0.0001f)<<CSL_EMIF4F_SDRAM_TIM_1_REG_T_RAS_SHIFT)|
((unsigned int)(49.5*clock_MHz/1000.f-0.0001f)<<CSL_EMIF4F_SDRAM_TIM_1_REG_T_RC_SHIFT)|
((unsigned int)(30*clock_MHz/(4*1000.f)-0.0001f)<<CSL_EMIF4F_SDRAM_TIM_1_REG_T_RRD_SHIFT)|
((unsigned int)(6*clock_MHz/1000.f-0.0001f)<<CSL_EMIF4F_SDRAM_TIM_1_REG_T_WTR_SHIFT);
DDR_Regs->SDRAM_TIM_2 = (5<<25)| /*ODTH8*/ //4A4F7FDA
((5-1)<<CSL_EMIF4F_SDRAM_TIM_2_REG_T_XP_SHIFT)|
((unsigned int)(120*clock_MHz/1000.f-0.0001f)<<CSL_EMIF4F_SDRAM_TIM_2_REG_T_XSNR_SHIFT)|
((512-1)<<CSL_EMIF4F_SDRAM_TIM_2_REG_T_XSRD_SHIFT)|
((unsigned int)(6*clock_MHz/1000.f-0.0001f)<<CSL_EMIF4F_SDRAM_TIM_2_REG_T_RTP_SHIFT)|
((3-1)<<CSL_EMIF4F_SDRAM_TIM_2_REG_T_CKE_SHIFT);
DDR_Regs->SDRAM_TIM_3 = //051F8498
((5)<<CSL_EMIF4F_SDRAM_TIM_3_REG_T_CSTA_SHIFT)|
((64-1)<<CSL_EMIF4F_SDRAM_TIM_3_REG_ZQ_ZQCS_SHIFT)|
((unsigned int)(110*clock_MHz/1000.f-0.0001f)<<CSL_EMIF4F_SDRAM_TIM_3_REG_T_RFC_SHIFT)|
((9-1)<<CSL_EMIF4F_SDRAM_TIM_3_REG_T_RAS_MAX_SHIFT);
DDR_Regs->DDR_PHY_CTRL_1 = 0x00100100| //00000000
(15<<CSL_EMIF4F_DDR_PHY_CTRL_1_REG_READ_LATENCY_SHIFT);
/*This is a JEDEC requirement that we have 500us delay between reset de-assert
and cke assert and then program the correct refresh rate
The DDR internal clock is divide by 16 before SDCFG write*/
DDR_Regs->SDRAM_REF_CTRL = 0x0000515C; //500 us
DDR_Regs->ZQ_CONFIG =
((0)<<CSL_EMIF4F_ZQ_CONFIG_REG_ZQ_CS1EN_SHIFT)|
((1)<<CSL_EMIF4F_ZQ_CONFIG_REG_ZQ_CS0EN_SHIFT)|
((0)<<CSL_EMIF4F_ZQ_CONFIG_REG_ZQ_DUALCALEN_SHIFT)|
((1)<<CSL_EMIF4F_ZQ_CONFIG_REG_ZQ_SFEXITEN_SHIFT)|
((1)<<CSL_EMIF4F_ZQ_CONFIG_REG_ZQ_ZQINIT_MULT_SHIFT)|
((3)<<CSL_EMIF4F_ZQ_CONFIG_REG_ZQ_ZQCL_MULT_SHIFT)|
((0x4C1F)<<CSL_EMIF4F_ZQ_CONFIG_REG_ZQ_REFINTERVAL_SHIFT);
/*map priority 0,1,2,3 to COS0,
map priority 3,5,6,7 to COS1*/
DDR_Regs->PRI_COS_MAP =
((1)<<CSL_EMIF4F_PRI_COS_MAP_REG_PRI_COS_MAP_EN_SHIFT)|
((1)<<CSL_EMIF4F_PRI_COS_MAP_REG_PRI_7_COS_SHIFT)|
((1)<<CSL_EMIF4F_PRI_COS_MAP_REG_PRI_6_COS_SHIFT)|
((1)<<CSL_EMIF4F_PRI_COS_MAP_REG_PRI_5_COS_SHIFT)|
((1)<<CSL_EMIF4F_PRI_COS_MAP_REG_PRI_4_COS_SHIFT)|
((0)<<CSL_EMIF4F_PRI_COS_MAP_REG_PRI_3_COS_SHIFT)|
((0)<<CSL_EMIF4F_PRI_COS_MAP_REG_PRI_2_COS_SHIFT)|
((0)<<CSL_EMIF4F_PRI_COS_MAP_REG_PRI_1_COS_SHIFT)|
((0)<<CSL_EMIF4F_PRI_COS_MAP_REG_PRI_0_COS_SHIFT);
/*master based COS map is disabled*/
DDR_Regs->MSTID_COS_1_MAP= 0;
DDR_Regs->MSTID_COS_2_MAP= 0;
/*LAT_CONFIG*/
DDR_Regs->VBUSM_CONFIG=
(8<<CSL_EMIF4F_VBUSM_CONFIG_REG_COS_COUNT_1_SHIFT)|
(16<<CSL_EMIF4F_VBUSM_CONFIG_REG_COS_COUNT_2_SHIFT)|
(32<<CSL_EMIF4F_VBUSM_CONFIG_REG_PR_OLD_COUNT_SHIFT);
DDR_Regs->ECC_CTRL =
((0)<<CSL_EMIF4F_ECC_CTRL_REG_ECC_EN_SHIFT)|
((0)<<CSL_EMIF4F_ECC_CTRL_REG_ECC_ADDR_RNG_PROT_SHIFT)|
((0)<<CSL_EMIF4F_ECC_CTRL_REG_ECC_ADDR_RNG_2_EN_SHIFT)|
((0)<<CSL_EMIF4F_ECC_CTRL_REG_ECC_ADDR_RNG_1_EN_SHIFT);
DDR_Regs->SDRAM_CONFIG =
(3<<CSL_EMIF4F_SDRAM_CONFIG_REG_SDRAM_TYPE_SHIFT)|
(0<<CSL_EMIF4F_SDRAM_CONFIG_REG_IBANK_POS_SHIFT)|
(DDR_TERM_RZQ_OVER_6<<CSL_EMIF4F_SDRAM_CONFIG_REG_DDR_TERM_SHIFT)|
(DDR_DYN_ODT_OVER_2<<CSL_EMIF4F_SDRAM_CONFIG_REG_DYN_ODT_SHIFT)|
(0<<CSL_EMIF4F_SDRAM_CONFIG_REG_DDR_DISABLE_DLL_SHIFT)|
(SDRAM_DRIVE_RZQ_OVER_7<<CSL_EMIF4F_SDRAM_CONFIG_REG_SDRAM_DRIVE_SHIFT)|
(DDR_CWL_7<<CSL_EMIF4F_SDRAM_CONFIG_REG_CWL_SHIFT)|
(DDR_BUS_WIDTH_64<<CSL_EMIF4F_SDRAM_CONFIG_REG_NARROW_MODE_SHIFT)|
(DDR_CL_9<<CSL_EMIF4F_SDRAM_CONFIG_REG_CL_SHIFT)|
(DDR_ROW_SIZE_13_BIT<<CSL_EMIF4F_SDRAM_CONFIG_REG_ROWSIZE_SHIFT)|
(DDR_BANK_NUM_8<<CSL_EMIF4F_SDRAM_CONFIG_REG_IBANK_SHIFT)|
(0<<CSL_EMIF4F_SDRAM_CONFIG_REG_EBANK_SHIFT)|
(DDR_PAGE_SIZE_10_BIT_1024_WORD<<CSL_EMIF4F_SDRAM_CONFIG_REG_PAGESIZE_SHIFT);
//initial vale for leveling
boot_cfg_regs->DDR3_CONFIG_REG[14] = 0x3C;
boot_cfg_regs->DDR3_CONFIG_REG[15] = 0x3C;
boot_cfg_regs->DDR3_CONFIG_REG[16] = 0x23;
boot_cfg_regs->DDR3_CONFIG_REG[17] = 0x2D;
boot_cfg_regs->DDR3_CONFIG_REG[18] = 0x13;
boot_cfg_regs->DDR3_CONFIG_REG[19] = 0x11;
boot_cfg_regs->DDR3_CONFIG_REG[20] = 0x9;
boot_cfg_regs->DDR3_CONFIG_REG[21] = 0xC;
boot_cfg_regs->DDR3_CONFIG_REG[22] = 0x21;
boot_cfg_regs->DDR3_CONFIG_REG[2] = 0x0;
boot_cfg_regs->DDR3_CONFIG_REG[3] = 0x0;
boot_cfg_regs->DDR3_CONFIG_REG[4] = 0x0;
boot_cfg_regs->DDR3_CONFIG_REG[5] = 0x0;
boot_cfg_regs->DDR3_CONFIG_REG[6] = 0x0;
boot_cfg_regs->DDR3_CONFIG_REG[7] = 0x0;
boot_cfg_regs->DDR3_CONFIG_REG[8] = 0x0;
boot_cfg_regs->DDR3_CONFIG_REG[9] = 0x0;
boot_cfg_regs->DDR3_CONFIG_REG[10] = 0x0;
boot_cfg_regs->DDR3_CONFIG_REG[0] |= 0xF;
boot_cfg_regs->DDR3_CONFIG_REG[23] |= 0x00000200; //Set bit 9 = 1 to use forced ratio leveling for read DQS
//enable full leveling, no incremental leveling
/*Typically you program the ramp window for a higher rate of
incremental leveling, meaning the 3 fields in the ramp control
register will be smaller than the corresponding fields in the
RDWR_LVL_CTRL.*/
DDR_Regs->RDWR_LVL_RMP_WIN = 4096;
DDR_Regs->RDWR_LVL_RMP_CTRL =
(1<<CSL_EMIF4F_RDWR_LVL_RMP_CTRL_REG_RDWRLVL_EN_SHIFT)|
(16<<CSL_EMIF4F_RDWR_LVL_RMP_CTRL_REG_RDWRLVLINC_RMP_PRE_SHIFT)|
(0<<CSL_EMIF4F_RDWR_LVL_RMP_CTRL_REG_RDLVLINC_RMP_INT_SHIFT)|
(0<<CSL_EMIF4F_RDWR_LVL_RMP_CTRL_REG_RDLVLGATEINC_RMP_INT_SHIFT)|
(0<<CSL_EMIF4F_RDWR_LVL_RMP_CTRL_REG_WRLVLINC_RMP_INT_SHIFT);
DDR_Regs->RDWR_LVL_CTRL =
(1<<CSL_EMIF4F_RDWR_LVL_CTRL_REG_RDWRLVLFULL_START_SHIFT)|
(32<<CSL_EMIF4F_RDWR_LVL_CTRL_REG_RDWRLVLINC_PRE_SHIFT)|
(0<<CSL_EMIF4F_RDWR_LVL_CTRL_REG_RDLVLINC_INT_SHIFT)|
(0<<CSL_EMIF4F_RDWR_LVL_CTRL_REG_RDLVLGATEINC_INT_SHIFT)|
(0<<CSL_EMIF4F_RDWR_LVL_CTRL_REG_WRLVLINC_INT_SHIFT);
// DDR_Regs->SDRAM_REF_CTRL = 64000000/8192/(1000/clock_MHz);
DDR_Regs->SDRAM_REF_CTRL = 64000.f*clock_MHz/8192.f;
CSL_BootCfgLockKicker();
printf("DDR Initialization Passed!\n");
}
Phyllis Xu:
回复 andy lee1:
您好!
你在程序中include了csl_bootcfgAux.h这个头文件中有很多宏定义,可能会导致不能在expression中看到结构体成员的内容。
比如像这种函数: CSL_FINS( )
非常感谢!
andy lee1:
回复 Phyllis Xu:
您好!
1.请问在expression里观察不到值和程序的实际运行结果有关系吗?
2.我进行在线仿真的时候在expressions里观察不到值,可是下载到EVM板上的时候大部分变量没显示“unexpected token”错误,只有两个变量还有这个错误,请问为什么两种仿真会出现这样的差别呢?
3.我在memory browser中能观察到变量是有值的,这是否意味着程序实际运行时没问题的,只不过由于某种未知的原因在expression里观察不到?
谢谢!
Phyllis Xu:
回复 andy lee1:
您好!
expression中观察不到值和实际运行结果没有必然联系,由于CCS仿真器的某些原因导致register中的值无法再expression看到,并且CCS软仿和硬仿在查看寄存器的时候是有差异的。
所以建议还是在memory browser观察register的值比较保险而且最准确。
非常感谢!
andy lee1:
回复 Phyllis Xu:
您好!
我在memory browser里观察变量值的变化时,出现了这种错误:运行某个语句后,变量所在地址的值没有变化,应该赋给该变量的值赋给了其他地址。但只有部分变量出现了这样的情况。请问出现这种错误是什么原因呢?
另外,将程序下载到EVM板子上后,运行某条语句后,会出现三处地址的值在变化,并非只有当前语句中的变量值在变化,请问这种错误又是什么原因呢?
非常感谢!