This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hello,
I have been working on interfacing a chip with xintf and I don't know why but my processor keeps stopping the execution and when I hit the play button again, it shows emulator error.
I have pasted the code below. Please let me know if anyone know why this is happening.
========================================================CODE====================================================================
#include "DSP28x_Project.h" // Device Headerfile and Examples Include File
// Prototype statements for functions found within this file.
//interrupt void xint1_isr(void);
float ConvertToVolt(Uint16 adcValue);
void init_zone6(void);
volatile Uint16* addressPtr;
volatile Uint16 selfTestResult[4] = {0,0,0,0};
volatile Uint16 adcValue0, adcValue1, adcValue2, adcValue3;
#define memLocationZone6 (Uint16 volatile *)0x100000 //Zone 6 address for ADC
#define memLocZone6ResetReg (Uint16 volatile *)0x100003 //Zone 6 address for ADC
#define bitStatusRegAddress (Uint16 volatile *)0x10001C //result of BIT test register of 1553
//#define memLocationZone6 0x100000
#define ADCPOSITIVEMAX 0x07FF
#define ADCNEGATIVEMAX 0x0800
// Global variables for this example
volatile Uint32 Xint1Count;
Uint16 highCount;
Uint16 lowCount;
Uint32 LoopCount;
float dataChannel[4];
float tenReadings[10];
float averageOfTen;
#define DELAY 35.700L
//#define ENABLE_EXT_INT
void main(void)
{
Uint16 sampleCount;
// Uint32 TempX2Count;
// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the DSP2833x_SysCtrl.c file.
InitSysCtrl();
// Step 2. Initialize GPIO:
// This example function is found in the DSP2833x_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
// InitGpio(); // Skipped for this example
// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interrupts
DINT;
// Initialize PIE control registers to their default state.
// The default state is all PIE interrupts disabled and flags
// are cleared.
// This function is found in the DSP2833x_PieCtrl.c file.
InitPieCtrl();
// Disable CPU interrupts and clear all CPU interrupt flags:
IER = 0x0000;
IFR = 0x0000;
// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
// This will populate the entire table, even if the interrupt
// is not used in this example. This is useful for debug purposes.
// The shell ISR routines are found in DSP2833x_DefaultIsr.c.
// This function is found in DSP2833x_PieVect.c.
InitPieVectTable();
// Interrupts that are used in this example are re-mapped to
// ISR functions found within this file.
// Step 4. Initialize all the Device Peripherals:
// This function is found in DSP2833x_InitPeripherals.c
// InitPeripherals(); // Not required for this example
// Step 5. User specific code, enable interrupts:
// Clear the counters
Xint1Count = 0; // Count Xint1 interrupts
LoopCount = 0; // Count times through idle loop
highCount = 0;
lowCount = 0;
for(sampleCount = 0; sampleCount<10; sampleCount++)
tenReadings[sampleCount] = 0;
averageOfTen = 0;
// Initalize XINTF Zone 0
init_zone6();
// GPIO34 as CONVST
EALLOW;
GpioDataRegs.GPBSET.bit.GPIO34 = 1; // Load the output latch
GpioCtrlRegs.GPBMUX1.bit.GPIO34 = 0; // GPIO
GpioCtrlRegs.GPBDIR.bit.GPIO34 = 1; // output
EDIS;
// GPIO18 as INT
EALLOW;
GpioCtrlRegs.GPAMUX2.bit.GPIO18 = 0; // GPIO
GpioCtrlRegs.GPADIR.bit.GPIO18 = 0; // input
EDIS;
EALLOW;
/*GPIO55 as MEM/REG_BAR selector*/
GpioCtrlRegs.GPBMUX2.bit.GPIO55 = 0; // GPIO function
GpioCtrlRegs.GPBDIR.bit.GPIO55 = 1; // output
/* GPIO53 as function entry indication*/
GpioCtrlRegs.GPBMUX2.bit.GPIO53 = 0; // GPIO function
GpioCtrlRegs.GPBDIR.bit.GPIO53 = 1; // output
EDIS;
while(1)
{
// GpioDataRegs.GPBCLEAR.bit.GPIO53 = 1; // Lower GPIO53 for 1us
//// DELAY_US(1);
//
// GpioDataRegs.GPBCLEAR.bit.GPIO55 = 1; // Lower GPIO55 for register selection
// DELAY_US(35);
addressPtr = memLocZone6ResetReg;
*addressPtr = 0x0001;
/*Self test requires 2ms to finish. wait for finish*/
// DELAY_US(1000);
/*Read result of self test*/
selfTestResult[0] = *bitStatusRegAddress;
addressPtr = memLocZone6ResetReg;
*addressPtr = 0x0001;
/*Self test requires 2ms to finish. wait for finish*/
// DELAY_US(1000);
/*Read result of self test*/
selfTestResult[1] = *bitStatusRegAddress;
//
GpioDataRegs.GPBSET.bit.GPIO53 = 1; // Raise GPIO53, trigger Xint1
}
}//end main
// Configure the timing paramaters for Zone 6.
// Notes:
// This function should not be executed from XINTF
// Adjust the timing based on the data manual and
// external device requirements.
void init_zone6(void)
{
// Make sure the XINTF clock is enabled
SysCtrlRegs.PCLKCR3.bit.XINTFENCLK = 1;
// Configure the GPIO for XINTF with a 16-bit data bus
// This function is in DSP2833x_Xintf.c
InitXintf16Gpio();
EALLOW;
// All Zones---------------------------------
// Timing for all zones based on XTIMCLK = SYSCLKOUT/2
XintfRegs.XINTCNF2.bit.XTIMCLK = 1;
// no buffer for write
XintfRegs.XINTCNF2.bit.WRBUFF = 0;
// XCLKOUT is disabled
XintfRegs.XINTCNF2.bit.CLKOFF = 1;
// XCLKOUT = XTIMCLK
XintfRegs.XINTCNF2.bit.CLKMODE = 1;
// Zone 6------------------------------------
// When using ready, ACTIVE must be 1 or greater
// Lead must always be 1 or greater
// Zone write timing for 1553 @150MHz
XintfRegs.XTIMING7.bit.XWRLEAD = 1;
XintfRegs.XTIMING7.bit.XWRACTIVE = 7;
XintfRegs.XTIMING7.bit.XWRTRAIL = 1;
//
// // Zone read timing for 1553 @150MHz
XintfRegs.XTIMING7.bit.XRDLEAD = 1;
XintfRegs.XTIMING7.bit.XRDACTIVE = 7;
XintfRegs.XTIMING7.bit.XRDTRAIL = 1;
XintfRegs.XTIMING7.bit.XWRLEAD = 1;
XintfRegs.XTIMING7.bit.XWRACTIVE = 0;
XintfRegs.XTIMING7.bit.XWRTRAIL = 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");
}
//===========================================================================
// No more.
==============================================================CODE-END=========================================================================
Akhil,
Can you elaborate on your emulator error message? Is it a permanent fail state or can you reconnect?
I see that you are trying to access Zone 6 addresses, but your code only configures the Zone 7 timing registers. Your initialization code also appears to configure the WR timings twice with different values:
// Zone 6------------------------------------
// When using ready, ACTIVE must be 1 or greater
// Lead must always be 1 or greater
// Zone write timing for 1553 @150MHz
XintfRegs.XTIMING7.bit.XWRLEAD = 1;
XintfRegs.XTIMING7.bit.XWRACTIVE = 7;
XintfRegs.XTIMING7.bit.XWRTRAIL = 1;
//
// // Zone read timing for 1553 @150MHz
XintfRegs.XTIMING7.bit.XRDLEAD = 1;
XintfRegs.XTIMING7.bit.XRDACTIVE = 7;
XintfRegs.XTIMING7.bit.XRDTRAIL = 1;
XintfRegs.XTIMING7.bit.XWRLEAD = 1;
XintfRegs.XTIMING7.bit.XWRACTIVE = 0;
XintfRegs.XTIMING7.bit.XWRTRAIL = 0;
// 1,1 = x16 data bus
// 0,1 = x32 data bus
// other values are reserved
XintfRegs.XTIMING7.bit.XSIZE = 3;
-Tommy
Hey Tommy,
I am able to reconnect to the dsp once i do the power on reset. And about the code, I might have pasted the wrong one! I am really sorry for that. The below one is the actual code. Please have a look at it and let me know if I am doing something wrong.
#define memLocationZone6 (Uint16 volatile *)0x100000 //Zone 6 address for ADC
#define memLocZone6ResetReg (Uint16 volatile *)0x100003 //Zone 6 address for ADC
#define bitStatusRegAddressZone6 (Uint16 volatile *)0x10001C //result of BIT test register of 1553
#endif
#if ENABLE_ZONE7
void init_zone7(void);
#define memLocationZone7 (Uint16 volatile *)0x200000 //Zone 7 address for ADC
#define memLocZone7ResetReg (Uint16 volatile *)0x200003
#define bitStatusRegAddressZone7 (Uint16 volatile *)0x20001C //result of BIT test register of 1553
#endif
volatile Uint16* addressPtr;
volatile Uint16 selfTestResult[2] = {0,0};
volatile Uint16 flagREADYD,flagIOEN;
// Global variables for this example
void main(void)
{
// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the DSP2833x_SysCtrl.c file.
InitSysCtrl();
// Step 2. Initialize GPIO:
// This example function is found in the DSP2833x_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
// InitGpio(); // Skipped for this example
// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interrupts
DINT;
// Initialize PIE control registers to their default state.
// The default state is all PIE interrupts disabled and flags
// are cleared.
// This function is found in the DSP2833x_PieCtrl.c file.
InitPieCtrl();
// Disable CPU interrupts and clear all CPU interrupt flags:
IER = 0x0000;
IFR = 0x0000;
// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
// This will populate the entire table, even if the interrupt
// is not used in this example. This is useful for debug purposes.
// The shell ISR routines are found in DSP2833x_DefaultIsr.c.
// This function is found in DSP2833x_PieVect.c.
InitPieVectTable();
#if ENABLE_ZONE6
// Initalize XINTF Zone 6
init_zone6();
#endif
#if ENABLE_ZONE7
// Initalize XINTF Zone 7
init_zone7();
#endif
selfTestResult[0] = 1;
EALLOW;
SysCtrlRegs.SCSR|= 0x0000;
EDIS;
if((SysCtrlRegs.WDCR & 0x0080) == 0)
{
//WakeCount++;
// Enable the watchdog
EALLOW;
SysCtrlRegs.WDCR = 0x0028;
// SysCtrlRegs.WDCR |= 0x0080;
EDIS;
}
EALLOW;
//STRBD
GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 0;
GpioCtrlRegs.GPADIR.bit.GPIO0 = 1;
//MEM/REG
GpioCtrlRegs.GPAMUX1.bit.GPIO1 = 0;
GpioCtrlRegs.GPADIR.bit.GPIO1 = 1;
//READYD
GpioCtrlRegs.GPAMUX1.bit.GPIO2 = 0;
GpioCtrlRegs.GPADIR.bit.GPIO2 = 0;
GpioCtrlRegs.GPAPUD.bit.GPIO2 = 1;
//IOEN
GpioCtrlRegs.GPAMUX1.bit.GPIO3 = 0;
GpioCtrlRegs.GPADIR.bit.GPIO3 = 0;
GpioCtrlRegs.GPAPUD.bit.GPIO3 = 0;
EDIS;
while(1)
{
GpioDataRegs.GPADAT.bit.GPIO1 = 0;
addressPtr = memLocZone6ResetReg;
GpioDataRegs.GPADAT.bit.GPIO0 = 1;
// asm("RPT #0 ||NOP");
// asm(" RPT #0 || NOP");
GpioDataRegs.GPADAT.bit.GPIO0 = 0;
*addressPtr = 0x0001;
asm(" RPT #3 || NOP");
if(GpioDataRegs.GPBDAT.bit.GPIO34 == 0)
{
selfTestResult[0] = *bitStatusRegAddressZone6;
GpioDataRegs.GPADAT.bit.GPIO0 = 1;
//asm("RPT #0 ||NOP");
asm(" RPT #3 || NOP");
}
}
}//end main
// Configure the timing paramaters for Zone 6.
// Notes:
// This function should not be executed from XINTF
// Adjust the timing based on the data manual and
// external device requirements.
void init_zone6(void)
{
// Make sure the XINTF clock is enabled
SysCtrlRegs.PCLKCR3.bit.XINTFENCLK = 1;
// Configure the GPIO for XINTF with a 16-bit data bus
// This function is in DSP2833x_Xintf.c
InitXintf16Gpio();
EALLOW;
// All Zones---------------------------------
// Timing for all zones based on XTIMCLK = SYSCLKOUT/2
XintfRegs.XINTCNF2.bit.XTIMCLK = 1;
// no buffer for write
XintfRegs.XINTCNF2.bit.WRBUFF = 0;
// XCLKOUT is disabled
XintfRegs.XINTCNF2.bit.CLKOFF = 1;
// XCLKOUT = XTIMCLK
XintfRegs.XINTCNF2.bit.CLKMODE = 1;
// Zone 6------------------------------------
// When using ready, ACTIVE must be 1 or greater
// Lead must always be 1 or greater
// Zone write timing for 1553 @150MHz
XintfRegs.XTIMING6.bit.XWRLEAD = 1;
XintfRegs.XTIMING6.bit.XWRACTIVE = 7;
XintfRegs.XTIMING6.bit.XWRTRAIL = 1;
// Zone read timing for 1553 @150MHz
XintfRegs.XTIMING6.bit.XRDLEAD = 1;
XintfRegs.XTIMING6.bit.XRDACTIVE = 7;
XintfRegs.XTIMING6.bit.XRDTRAIL = 1;
// Double all Zone read/write lead/active/trail timing
XintfRegs.XTIMING6.bit.X2TIMING = 0;
// Zone will sample XREADY signal
XintfRegs.XTIMING6.bit.USEREADY = 1;
//XREADY in synchronous mode
XintfRegs.XTIMING7.bit.READYMODE = 1;
// 1,1 = x16 data bus
// 0,1 = x32 data bus
// other values are reserved
XintfRegs.XTIMING6.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");
}
Akhil,
I would suggest to scope the XRSn pin and make sure the workaround is working as expected. Let us know what do you find.
Regards,
Vivek Singh