DSPRelated.com
Forums

linker error for f2812

Started by baha...@hotmail.com January 12, 2009
HI all,
I am a new user of F2812 TI DSP.
I read a previous posts form you recommending TI examples for beginners to trace.
So I started with the CPU timer example v111.
I built a code which toggles Pin0 on port A using timer 0 interrupt and use it as the main code in that project.
Below is my code.

#include "DSP281x_Device.h"

// Prototype statements for functions found within this file.

void Gpio_select(void);
void InitSystem(void);
interrupt void CpuTimer0Isr(void);
void ServeWD(void);

void main(void)
{
//long i=0;
// Initialize the DSP's core Registers with
InitSystem();

// Setup the GPIO Multiplex Registers
Gpio_select();

InitPieCtrl();

// 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 DSP281x_DefaultIsr.c.
// This function is found in DSP281x_PieVect.c.
InitPieVectTable();

// Interrupts that are used here are re-mapped to
// ISR functions found within this file.
//instead of edting in the TI function we assign the ISR to our new function
EALLOW; // This is needed to write to EALLOW protected registers
PieVectTable.TINT0 = &CpuTimer0Isr;//remapping step
EDIS; // This is needed to disable write to EALLOW protected registers

InitCpuTimers();

// Configure CPU-Timer 0 to interrupt every 50 ms:
// 150MHz CPU Freq, 50000 µseconds interrupt period
ConfigCpuTimer(&CpuTimer0, 150, 50000);

PieCtrlRegs.PIEIER1.bit.INTx7=1; //enable T0 interrupt
IER|= 0x0001; //enable the first set of interrupts which T0 part of
EINT; //Enable global interrrupt
ERTM;
StartCpuTimer0();//equivelant to CpuTimer0Regs.TCR.bit.TSS = 0; you can find it in the CPU timer.h_start timer zero to run
while(1)
{
ServeWD();
//EALLOW;
//SysCtrlRegs.WDKEY = 0x00AA;
//EDIS;
}
}

void CpuTimer0Isr(void)
{

CpuTimer0.InterruptCount++;
GpioDataRegs.GPATOGGLE.bit.GPIOA0 = 1;
ServeWD();
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; // Acknowledge this interrupt to get more from group 1
}

void Gpio_select(void)
{
EALLOW;
GpioMuxRegs.GPAMUX.all = 0x0000; // all GPIO port Pin's to I/O
GpioMuxRegs.GPBMUX.all = 0x0000;
GpioMuxRegs.GPDMUX.all = 0x0000;
GpioMuxRegs.GPFMUX.all = 0x0000;
GpioMuxRegs.GPEMUX.all = 0x0000;
GpioMuxRegs.GPGMUX.all = 0x0000;

GpioMuxRegs.GPADIR.all = 0xFFEF; // firt 4 pins of Port A are output and the the fifth pin is input and the rest are output.
GpioMuxRegs.GPBDIR.all = 0xFFFF; // GPIO output
GpioMuxRegs.GPDDIR.all = 0xFFFF; // GPIO PORT as output
GpioMuxRegs.GPEDIR.all = 0xFFFF; // GPIO PORT as output
GpioMuxRegs.GPFDIR.all = 0xFFFF; // GPIO PORT as output
GpioMuxRegs.GPGDIR.all = 0xFFFF; // GPIO PORT as output

GpioMuxRegs.GPAQUAL.all = 0x0000; // Set GPIO input qualifier values to zero
GpioMuxRegs.GPBQUAL.all = 0x0000;
GpioMuxRegs.GPDQUAL.all = 0x0000;
GpioMuxRegs.GPEQUAL.all = 0x0000;
EDIS;
}
void InitSystem(void)
{
EALLOW;
SysCtrlRegs.WDCR= 0x00AF; // Setup the watchdog
SysCtrlRegs.PLLCR.bit.DIV = 0xA; // Setup the Clock PLL to multiply by 5
SysCtrlRegs.SCSR = 0x0; // Watchdog(WDENINT)to generate a RESET
SysCtrlRegs.HISPCP.all = 0x0001; // Setup Highspeed Clock Prescaler to divide by 2
SysCtrlRegs.LOSPCP.all = 0x0002; // Setup Lowspeed CLock Prescaler to divide by 4

// Peripheral clock enables set for the selected peripherals.
SysCtrlRegs.PCLKCR.bit.EVAENCLK=0;
SysCtrlRegs.PCLKCR.bit.EVBENCLK=0;
SysCtrlRegs.PCLKCR.bit.SCIAENCLK=0;
SysCtrlRegs.PCLKCR.bit.SCIBENCLK=0;
SysCtrlRegs.PCLKCR.bit.MCBSPENCLK=0;
SysCtrlRegs.PCLKCR.bit.SPIENCLK=0;
SysCtrlRegs.PCLKCR.bit.ECANENCLK=0;
SysCtrlRegs.PCLKCR.bit.ADCENCLK=0;
EDIS;
}

void ServeWD(void)
{
//next 4 lines to serve the watchdog periodically.
EALLOW;
SysCtrlRegs.WDKEY = 0x55;
SysCtrlRegs.WDKEY = 0xAA;
EDIS;
}

//