Jump to content
Sign in to follow this  
timotet

Piccolo f28069 control stick

Recommended Posts

I dusted off my control stick yesterday  ;)

Imported a couple of example projects and setup a template for future projects with it.

 

I was wondering about the contolSuite driver library, and the control stick.

My current driver library is for the C2000 launchpad.

 

Is there a driver library for the f28069 ?

If there is do I need to set up a new workspace for it and have the library in it?

 

Thanks

Tim

Share this post


Link to post
Share on other sites

Tim,

Currently there is no driver library for the 06x devices, but the 02x library should work.  Almost all of the peripherals are the same, but some have additional functionality.  Driver libraries for the other devices are in the works, but there is no schedule for when these will be released.

Share this post


Link to post
Share on other sites

Ive been trying to write some code for the above mentioned control stick and I am having a rough go of it.

 

The chip on the stick is aTMX320F28069PNA not the TMS version. I've looked at the errata and there is nothing there to

explain the way this thing is working or in this case not working. I don't want to say that its a hardware issue due to the fact

that I'm not a pro at this by any means.

 

I am trying to port some code that runs great on my C2000 launch pad to the F28069 device I thought this would be a

relatively easy job but no dice , so I'm asking for some help.

 

First off when I plug in the device some times it shows up as Texas Instruments XDS100+RS232 V1.0,

and sometimes it shows up as a USB composite device.

Ive noticed if I try to upload code when it says USB composite device the target appears not to connect at all,

Ive tried to connect via the target configuration set up and it doesn't.

I've uninstalled , reinstalled the drivers over and over.

 

When I do get the target to connect and am able to upload code sometimes it sort of works as expected and most of the time not.

I can load the exact same code multiple times and sometimes it will debug and run and other times nothing. Frustrating!

 

Also I can not get the hardware SPI to work. Ive compared the register settings that work from the F28027 device to the F28069 device and they are exactly the same but once again no dice!

 

I've spent lots of time reading the reference guide for both the F28027 and F28069 and they are not that different,

actually the SPI looks to be exactly the same. Even if they are different it doesn't explain the erratic behavior of the device.

 

Here is the DeviceInit file I can share the whole project if need be.

 

 

//============================================================================
//============================================================================
//
// FILE:	DevInit_F2806x.c
//
// TITLE:	Device initialization for F2806x series
//
// Date: 	2/18/13
//============================================================================
//============================================================================

#include "PeripheralHeaderIncludes.h"
#include "colorLCD.h"

// Functions that will be run from RAM need to be assigned to
// a different section.  This section will then be mapped to a load and
// run address using the linker cmd file.
#pragma CODE_SECTION(InitFlash, "ramfuncs");
#define Device_cal (void   (*)(void))0x3D7C80

void DeviceInit(void);
void PieCntlInit(void);
void PieVectTableInit(void);
void WDogDisable(void);
void PLLset(Uint16);
void ISR_ILLEGAL(void);

//--------------------------------------------------------------------
//  Configure Device for target Application Here
//--------------------------------------------------------------------
void DeviceInit(void)
{
	WDogDisable(); 	// Disable the watchdog initially
	DINT;			// Global Disable all Interrupts
	IER = 0x0000;	// Disable CPU interrupts
	IFR = 0x0000;	// Clear all CPU interrupt flags


// The Device_cal function, which copies the ADC & oscillator calibration values
// from TI reserved OTP into the appropriate trim registers, occurs automatically
// in the Boot ROM. If the boot ROM code is bypassed during the debug process, the
// following function MUST be called for the ADC and oscillators to function according
// to specification.
	EALLOW;
	SysCtrlRegs.PCLKCR0.bit.ADCENCLK = 1; // Enable ADC peripheral clock
	(*Device_cal)();					  // Auto-calibrate from TI OTP
	SysCtrlRegs.PCLKCR0.bit.ADCENCLK = 0; // Return ADC clock to original state
	EDIS;


// Switch to Internal Oscillator 1 and turn off all other clock
// sources to minimize power consumption
	EALLOW;
	SysCtrlRegs.CLKCTL.bit.INTOSC1OFF = 0;
    SysCtrlRegs.CLKCTL.bit.OSCCLKSRCSEL=0;  // Clk Src = INTOSC1
	SysCtrlRegs.CLKCTL.bit.XCLKINOFF=1;     // Turn off XCLKIN
	SysCtrlRegs.CLKCTL.bit.XTALOSCOFF=1;    // Turn off XTALOSC
	SysCtrlRegs.CLKCTL.bit.INTOSC2OFF=1;    // Turn off INTOSC2
    EDIS;


// SYSTEM CLOCK speed based on internal oscillator = 10 MHz
// 0x10=  80    MHz		(16)
// 0xF =  75    MHz		(15)
// 0xE =  70    MHz		(14)
// 0xD =  65    MHz		(13)
// 0xC =  60	MHz		(12)
// 0xB =  55	MHz		(11)
// 0xA =  50	MHz		(10)
// 0x9 =  45	MHz		(9)
// 0x8 =  40	MHz		(8)
// 0x7 =  35	MHz		(7)
// 0x6 =  30	MHz		(6)
// 0x5 =  25	MHz		(5)
// 0x4 =  20	MHz		(4)
// 0x3 =  15	MHz		(3)
// 0x2 =  10	MHz		(2)

	PLLset( 0x10 );	// choose from options above

// Initialize interrupt controller and Vector Table
// to defaults for now. Application ISR mapping done later.
PieCntlInit();
PieVectTableInit();


   EALLOW; // below registers are "protected", allow access.

// LOW SPEED CLOCKS prescale register settings
   // GpioCtrlRegs.GPAMUX2.bit.GPIO18 = 3;  // GPIO18 = XCLKOUT
   SysCtrlRegs.LOSPCP.all = 0x0003 //0x0002 = Sysclk / 4(20 MHz)//0x0010 = Sysclk/2(40MHz)//0x0003 = Sysclk/6(13.3 MHz)
   SysCtrlRegs.XCLK.bit.XCLKOUTDIV=0;  //turn off XCLKOUT

// PERIPHERAL CLOCK ENABLES 
//---------------------------------------------------
// If you are not using a peripheral you may want to switch
// the clock off to save power, i.e. set to =0 
// 
// Note: not all peripherals are available on all 280x derivates.
// Refer to the datasheet for your particular device. 

   SysCtrlRegs.PCLKCR0.bit.ADCENCLK = 0;    // ADC
   //------------------------------------------------
   SysCtrlRegs.PCLKCR3.bit.COMP1ENCLK = 0;	// COMP1
   SysCtrlRegs.PCLKCR3.bit.COMP2ENCLK = 0;	// COMP2
   SysCtrlRegs.PCLKCR3.bit.COMP3ENCLK = 0;	// COMP3
   //------------------------------------------------
   SysCtrlRegs.PCLKCR0.bit.I2CAENCLK = 0;   // I2C
   //------------------------------------------------
   SysCtrlRegs.PCLKCR0.bit.SPIAENCLK = 1;	// SPI-A
   SysCtrlRegs.PCLKCR0.bit.SPIBENCLK = 0;	//SPI-B
   //------------------------------------------------
   SysCtrlRegs.PCLKCR0.bit.MCBSPAENCLK = 0;	//McBSP-A
   //------------------------------------------------
   SysCtrlRegs.PCLKCR0.bit.SCIAENCLK = 0;  	// SCI-A
   SysCtrlRegs.PCLKCR0.bit.SCIBENCLK = 0;	//SCI-B
   //------------------------------------------------
   SysCtrlRegs.PCLKCR1.bit.ECAP1ENCLK = 0;	//eCAP1
   SysCtrlRegs.PCLKCR1.bit.ECAP2ENCLK = 0;	// eCAP2
   SysCtrlRegs.PCLKCR1.bit.ECAP3ENCLK = 0;	// eCAP3
   //------------------------------------------------
   SysCtrlRegs.PCLKCR1.bit.EPWM1ENCLK = 0;  // ePWM1
   SysCtrlRegs.PCLKCR1.bit.EPWM2ENCLK = 0;  // ePWM2
   SysCtrlRegs.PCLKCR1.bit.EPWM3ENCLK = 0;  // ePWM3
   SysCtrlRegs.PCLKCR1.bit.EPWM4ENCLK = 0;  // ePWM4
   SysCtrlRegs.PCLKCR1.bit.EPWM5ENCLK = 0;	// ePWM5
   SysCtrlRegs.PCLKCR1.bit.EPWM6ENCLK = 0;	// ePWM6
   SysCtrlRegs.PCLKCR1.bit.EPWM7ENCLK = 0;	// ePWM7
   SysCtrlRegs.PCLKCR1.bit.EPWM8ENCLK = 0;	// ePWM8
   //------------------------------------------------
   SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0;   // Enable TBCLK
   //------------------------------------------------
   SysCtrlRegs.PCLKCR3.bit.DMAENCLK = 0;	// DMA
   //------------------------------------------------
   SysCtrlRegs.PCLKCR3.bit.CLA1ENCLK = 0;	// CLA
   //------------------------------------------------
                                 
//--------------------------------------------------------------------------------------
// GPIO (GENERAL PURPOSE I/O) CONFIG
//--------------------------------------------------------------------------------------
//-----------------------
// QUICK NOTES on USAGE:
//-----------------------
// If GpioCtrlRegs.GP?MUX?bit.GPIO?= 1, 2 or 3 (i.e. Non GPIO func), then leave
//	rest of lines commented
// If GpioCtrlRegs.GP?MUX?bit.GPIO?= 0 (i.e. GPIO func), then:
//	1) uncomment GpioCtrlRegs.GP?DIR.bit.GPIO? = ? and choose pin to be IN or OUT
//	2) If IN, can leave next to lines commented
//	3) If OUT, uncomment line with ..GPASET.. to force pin High or                        
//        uncomment line with ..GPACLEAR.. to force pin Low or  wtf! these are different for GPIO34
//--------------------------------------------------------------------------------------
   //  GPIO-00 - PIN FUNCTION = using for debug with external led
   GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 0;	// 0=GPIO, 1=EPWM1A, 2=Resv, 3=Resv
   GpioCtrlRegs.GPADIR.bit.GPIO0 = 0;      // 1=OUTput,  0=INput
   //GpioCtrlRegs.GPAPUD.bit.GPIO0 = 1;     // Disable pull-up on led 0=pull up
   //GpioDataRegs.GPACLEAR.bit.GPIO0 = 1;// uncomment if --> Set Low initially
   //GpioDataRegs.GPASET.bit.GPIO0 = 1;	 // uncomment if --> Set High initially
   	//--------------------------------------------------------------------------------------
//  GPIO-01 - PIN FUNCTION = --Spare--
    GpioCtrlRegs.GPAMUX1.bit.led1 = 0;	// 0=GPIO, 1=EPWM1B, 2=EMU (0), 3=COMP1OUT
    GpioCtrlRegs.GPADIR.bit.led1 = 1;	// 1=OUTput,  0=INput
    GpioCtrlRegs.GPAPUD.bit.led1 = 1;   // Disable pull-up on led 0=pull up
    GpioDataRegs.GPACLEAR.bit.led1 = 1;	// uncomment if --> Set Low initially
  //GpioDataRegs.GPASET.bit.led1 = 1;	// uncomment if --> Set High initially
//--------------------------------------------------------------------------------------
//  GPIO-02 - PIN FUNCTION = --Spare--
	GpioCtrlRegs.GPAMUX1.bit.GPIO2 = 0;	// 0=GPIO, 1=EPWM2A, 2=Resv, 3=Resv
	GpioCtrlRegs.GPADIR.bit.GPIO2 = 0;	// 1=OUTput,  0=INput
//	GpioDataRegs.GPACLEAR.bit.GPIO2 = 1;	// uncomment if --> Set Low initially
//	GpioDataRegs.GPASET.bit.GPIO2 = 1;	// uncomment if --> Set High initially
//--------------------------------------------------------------------------------------
//  GPIO-03 - PIN FUNCTION = --Spare--
	GpioCtrlRegs.GPAMUX1.bit.GPIO3 = 0;	// 0=GPIO, 1=EPWM2B, 2=SPISOMIA, 3=COMP2OUT
	GpioCtrlRegs.GPADIR.bit.GPIO3 = 0;	// 1=OUTput,  0=INput 
//	GpioDataRegs.GPACLEAR.bit.GPIO3 = 1;	// uncomment if --> Set Low initially
//	GpioDataRegs.GPASET.bit.GPIO3 = 1;	// uncomment if --> Set High initially
//--------------------------------------------------------------------------------------
//  GPIO-04 - PIN FUNCTION = --Spare--
	GpioCtrlRegs.GPAMUX1.bit.GPIO4 = 0;	// 0=GPIO, 1=EPWM3A, 2=Resv, 3=Resv
	GpioCtrlRegs.GPADIR.bit.GPIO4 = 0;	// 1=OUTput,  0=INput 
//	GpioDataRegs.GPACLEAR.bit.GPIO4 = 1;	// uncomment if --> Set Low initially
//	GpioDataRegs.GPASET.bit.GPIO4 = 1;	// uncomment if --> Set High initially
//--------------------------------------------------------------------------------------
// GPIO-05 - PIN FUNCTION = connect to DC of 2.2" LCD
   GpioCtrlRegs.GPAMUX1.bit.LCD_DC_PIN = 0; // 0=GPIO, 1=EPWM3B, 2=SPISIMOA, 3=ECAP1
   GpioCtrlRegs.GPADIR.bit.LCD_DC_PIN = 1;   // 1=OUTput,  0=INput
   GpioCtrlRegs.GPAPUD.bit.LCD_DC_PIN = 1;   // Disable pull-up on LCD_DC_PIN  0=pull up
   GpioDataRegs.GPACLEAR.bit.LCD_DC_PIN = 1; // uncomment if --> Set Low initially
 //GpioDataRegs.GPASET.bit.LCD_DC_PIN = 1;   // uncomment if --> Set High initially
//--------------------------------------------------------------------------------------
//GPIO-06 - PIN FUNCTION = connect to IRQ on 2.2" LCD
  GpioCtrlRegs.GPAMUX1.bit.TSC_PENIRQ_PIN = 0; // 0=GPIO, 1=EPWM4A, 2=EPWMSYNCI, 3=EPWMSYNCO
  GpioCtrlRegs.GPADIR.bit.TSC_PENIRQ_PIN = 0;// 1=OUTput,  0=INput
  GpioCtrlRegs.GPAPUD.bit.TSC_PENIRQ_PIN = 0;// Enable pull-up on TSC_PENIRQ_PIN  0=pull up
//GpioDataRegs.GPACLEAR.bit.TSC_PENIRQ_PIN = 1; // uncomment if --> Set Low initially
  GpioCtrlRegs.GPAQSEL1.bit.TSC_PENIRQ_PIN = 2;  // XINT1 sampled 6 times //2=  6 samples //1 = 3 samples
  GpioCtrlRegs.GPACTRL.bit.QUALPRD0 = 0xFF; // Each sampling window is 255*SYSCLKOUT
//--------------------------------------------------------------------------------------
//GPIO-07 - PIN FUNCTION =connect to TSC_CS_PIN on 2.2" LCD
  GpioCtrlRegs.GPAMUX1.bit.TSC_CS_PIN = 0; // 0=GPIO, 1=EPWM4B, 2=SCIRXDA, 3=ECAP2
  GpioCtrlRegs.GPADIR.bit.TSC_CS_PIN = 1;   // 1=OUTput,  0=INput
  GpioCtrlRegs.GPAPUD.bit.TSC_CS_PIN = 1;   // Disable pull-up on TSC_CS_PIN 0=pull up
  GpioDataRegs.GPACLEAR.bit.TSC_CS_PIN = 1; // uncomment if --> Set Low initially
//GpioDataRegs.GPASET.bit.TSC_CS_PIN = 1;   // uncomment if --> Set High initially
		//--------------------------------------------------------------------------------------
//  GPIO-12 - PIN FUNCTION = --Spare--
	GpioCtrlRegs.GPAMUX1.bit.GPIO12 = 0;	// 0=GPIO, 1=TZ1n, 2=SCITXDA, 3=SPISIMOB
	GpioCtrlRegs.GPADIR.bit.GPIO12 = 0;	// 1=OUTput,  0=INput 
//	GpioDataRegs.GPACLEAR.bit.GPIO12 = 1;	// uncomment if --> Set Low initially
//	GpioDataRegs.GPASET.bit.GPIO12 = 1;	// uncomment if --> Set High initially
//--------------------------------------------------------------------------------------
/*
	//  GPIO-16 - PIN FUNCTION = --Spare--
	GpioCtrlRegs.GPAMUX2.bit.GPIO16 = 1;	// 0=GPIO, 1=SPISIMOA, 2=Resv CAN-B, 3=TZ2n
	GpioCtrlRegs.GPADIR.bit.GPIO16 = 0;	// 1=OUTput,  0=INput 
//	GpioDataRegs.GPACLEAR.bit.GPIO16 = 1;	// uncomment if --> Set Low initially
//	GpioDataRegs.GPASET.bit.GPIO16 = 1;	// uncomment if --> Set High initially
//--------------------------------------------------------------------------------------
//  GPIO-17 - PIN FUNCTION = --Spare--
	GpioCtrlRegs.GPAMUX2.bit.GPIO17 = 1;	// 0=GPIO, 1=SPISOMIA, 2=Resv CAN-B, 3=TZ3n
	GpioCtrlRegs.GPADIR.bit.GPIO17 = 0;	// 1=OUTput,  0=INput 
//	GpioDataRegs.GPACLEAR.bit.GPIO17 = 1;	// uncomment if --> Set Low initially
//	GpioDataRegs.GPASET.bit.GPIO17 = 1;	// uncomment if --> Set High initially
//--------------------------------------------------------------------------------------
//  GPIO-18 - PIN FUNCTION = --Spare--
	GpioCtrlRegs.GPAMUX2.bit.GPIO18 = 1;	// 0=GPIO, 1=SPICLKA, 2=SCITXDB, 3=XCLKOUT
	GpioCtrlRegs.GPADIR.bit.GPIO18 = 0;	// 1=OUTput,  0=INput 
//	GpioDataRegs.GPACLEAR.bit.GPIO18 = 1;	// uncomment if --> Set Low initially
//	GpioDataRegs.GPASET.bit.GPIO18 = 1;	// uncomment if --> Set High initially
//--------------------------------------------------------------------------------------
//  GPIO-19 - PIN FUNCTION = --Spare--
	GpioCtrlRegs.GPAMUX2.bit.GPIO19 = 1;	// 0=GPIO, 1=SPISTEA, 2=SCIRXDB, 3=ECAP1
	GpioCtrlRegs.GPADIR.bit.GPIO19 = 0;	// 1=OUTput,  0=INput 
//	GpioDataRegs.GPACLEAR.bit.GPIO19 = 1;	// uncomment if --> Set Low initially
//	GpioDataRegs.GPASET.bit.GPIO19 = 1;     // uncomment if --> Set High initially
 */
//--------------------------------------------------------------------------------------
//  GPIO-32 - PIN FUNCTION = --Spare--
	GpioCtrlRegs.GPBMUX1.bit.GPIO32 = 0;	// 0=GPIO,  1=I2C-SDA,  2=SYNCI,  3=ADCSOCA
	GpioCtrlRegs.GPBDIR.bit.GPIO32 = 0;	// 1=OUTput,  0=INput 
//	GpioDataRegs.GPBCLEAR.bit.GPIO32 = 1;	// uncomment if --> Set Low initially
//	GpioDataRegs.GPBSET.bit.GPIO32 = 1;	// uncomment if --> Set High initially
//--------------------------------------------------------------------------------------
//  GPIO-33 - PIN FUNCTION = --Spare--
	GpioCtrlRegs.GPBMUX1.bit.GPIO33 = 0;	// 0=GPIO,  1=I2C-SCL,  2=SYNCO,  3=ADCSOCB
	GpioCtrlRegs.GPBDIR.bit.GPIO33 = 0;	// 1=OUTput,  0=INput 
//	GpioDataRegs.GPBCLEAR.bit.GPIO33 = 1;	// uncomment if --> Set Low initially
//	GpioDataRegs.GPBSET.bit.GPIO33 = 1;	// uncomment if --> Set High initially
//--------------------------------------------------------------------------------------
//  GPIO-34 - PIN FUNCTION = LED for F2806x USB dongle
   GpioCtrlRegs.GPBPUD.bit.led = 1;     //Disable pull-up on led 0=pull up
   GpioCtrlRegs.GPBMUX1.bit.led = 0;	// 0=GPIO,  1=COMP2OUT,  2=EMU1,  3=Resv
   //GpioDataRegs.GPBCLEAR.bit.led = 1;	// uncomment if --> Set High initially  backwards!!!!!
   GpioDataRegs.GPBSET.bit.led = 1;	// uncomment if --> Set Low  initially  backwards!!!!!
   GpioCtrlRegs.GPBDIR.bit.led = 1;	// 1=OUTput,  0=INput
//--------------------------------------------------------------------------------------
	EDIS;	// Disable register access
}
/////// disable the watchdog //////
void WDogDisable(void)
{
    EALLOW;
    SysCtrlRegs.WDCR= 0x0068;
    EDIS;
}

// This function initializes the PLLCR register.
//void InitPll(Uint16 val, Uint16 clkindiv)
void PLLset(Uint16 val)
{
   volatile Uint16 iVol;

   // Make sure the PLL is not running in limp mode
   if (SysCtrlRegs.PLLSTS.bit.MCLKSTS != 0)
   {
	  EALLOW;
      // OSCCLKSRC1 failure detected. PLL running in limp mode.
      // Re-enable missing clock logic.
      SysCtrlRegs.PLLSTS.bit.MCLKCLR = 1;
      EDIS;
      // Replace this line with a call to an appropriate
      // SystemShutdown(); function.
      asm("        ESTOP0");     // Uncomment for debugging purposes
   }

   // DIVSEL MUST be 0 before PLLCR can be changed from
   // 0x0000. It is set to 0 by an external reset XRSn
   // This puts us in 1/4
   if (SysCtrlRegs.PLLSTS.bit.DIVSEL != 0)
   {
       EALLOW;
       SysCtrlRegs.PLLSTS.bit.DIVSEL = 0;
       EDIS;
   }

   // Change the PLLCR
   if (SysCtrlRegs.PLLCR.bit.DIV != val)
   {

      EALLOW;
      // Before setting PLLCR turn off missing clock detect logic
      SysCtrlRegs.PLLSTS.bit.MCLKOFF = 1;
      SysCtrlRegs.PLLCR.bit.DIV = val;
      EDIS;

      // Optional: Wait for PLL to lock.
      // During this time the CPU will switch to OSCCLK/2 until
      // the PLL is stable.  Once the PLL is stable the CPU will
      // switch to the new PLL value.
      //
      // This time-to-lock is monitored by a PLL lock counter.
      //
      // Code is not required to sit and wait for the PLL to lock.
      // However, if the code does anything that is timing critical,
      // and requires the correct clock be locked, then it is best to
      // wait until this switching has completed.

      // Wait for the PLL lock bit to be set.
      // The watchdog should be disabled before this loop, or fed within
      // the loop via ServiceDog().

	  // Uncomment to disable the watchdog
      WDogDisable();

	  while(SysCtrlRegs.PLLSTS.bit.PLLLOCKS != 1) {}

      EALLOW;
      SysCtrlRegs.PLLSTS.bit.MCLKOFF = 0;
	  EDIS;
	}

	  //divide down SysClk by 2 to increase stability
	EALLOW;
	SysCtrlRegs.PLLSTS.bit.DIVSEL = 2; 
	EDIS;
}

// This function initializes the PIE control registers to a known state.
//
void PieCntlInit(void)
{
    // Disable Interrupts at the CPU level:
    DINT;

    // Disable the PIE
    PieCtrlRegs.PIECTRL.bit.ENPIE = 0;

	// Clear all PIEIER registers:
	PieCtrlRegs.PIEIER1.all = 0;
	PieCtrlRegs.PIEIER2.all = 0;
	PieCtrlRegs.PIEIER3.all = 0;	
	PieCtrlRegs.PIEIER4.all = 0;
	PieCtrlRegs.PIEIER5.all = 0;
	PieCtrlRegs.PIEIER6.all = 0;
	PieCtrlRegs.PIEIER7.all = 0;
	PieCtrlRegs.PIEIER8.all = 0;
	PieCtrlRegs.PIEIER9.all = 0;
	PieCtrlRegs.PIEIER10.all = 0;
	PieCtrlRegs.PIEIER11.all = 0;
	PieCtrlRegs.PIEIER12.all = 0;

	// Clear all PIEIFR registers:
	PieCtrlRegs.PIEIFR1.all = 0;
	PieCtrlRegs.PIEIFR2.all = 0;
	PieCtrlRegs.PIEIFR3.all = 0;	
	PieCtrlRegs.PIEIFR4.all = 0;
	PieCtrlRegs.PIEIFR5.all = 0;
	PieCtrlRegs.PIEIFR6.all = 0;
	PieCtrlRegs.PIEIFR7.all = 0;
	PieCtrlRegs.PIEIFR8.all = 0;
	PieCtrlRegs.PIEIFR9.all = 0;
	PieCtrlRegs.PIEIFR10.all = 0;
	PieCtrlRegs.PIEIFR11.all = 0;
	PieCtrlRegs.PIEIFR12.all = 0;
}	

void PieVectTableInit(void)
{
	int16 i;
   	PINT *Dest = &PieVectTable.TINT1;

   	EALLOW;
   	for(i=0; i < 115; i++) 
    *Dest++ = &ISR_ILLEGAL;
   	EDIS;
 
   	// Enable the PIE Vector Table
   	PieCtrlRegs.PIECTRL.bit.ENPIE = 1; 	
}

interrupt void ISR_ILLEGAL(void)   // Illegal operation TRAP
{
  // Insert ISR Code here

  // Next two lines for debug only to halt the processor here
  // Remove after inserting ISR Code
  asm("          ESTOP0");
  for(;;

}

// This function initializes the Flash Control registers

//                   CAUTION
// This function MUST be executed out of RAM. Executing it
// out of OTP/Flash will yield unpredictable results

void InitFlash(void)
{
   EALLOW;
   //Enable Flash Pipeline mode to improve performance
   //of code executed from Flash.
   FlashRegs.FOPT.bit.ENPIPE = 1;

   //                CAUTION
   //Minimum waitstates required for the flash operating
   //at a given CPU rate must be characterized by TI.
   //Refer to the datasheet for the latest information.

   //Set the Paged Waitstate for the Flash
   FlashRegs.FBANKWAIT.bit.PAGEWAIT = 3;

   //Set the Random Waitstate for the Flash
   FlashRegs.FBANKWAIT.bit.RANDWAIT = 3;

   //Set the Waitstate for the OTP
   FlashRegs.FOTPWAIT.bit.OTPWAIT = 5;

   //                CAUTION
   //ONLY THE DEFAULT VALUE FOR THESE 2 REGISTERS SHOULD BE USED
   FlashRegs.FSTDBYWAIT.bit.STDBYWAIT = 0x01FF;
   FlashRegs.FACTIVEWAIT.bit.ACTIVEWAIT = 0x01FF;
   EDIS;

   //Force a pipeline flush to ensure that the write to
   //the last register configured occurs before returning.

   asm(" RPT #7 || NOP");
}


// This function will copy the specified memory contents from
// one location to another. 
// 
//	Uint16 *SourceAddr        Pointer to the first word to be moved
//                          SourceAddr < SourceEndAddr
//	Uint16* SourceEndAddr     Pointer to the last word to be moved
//	Uint16* DestAddr          Pointer to the first destination word
//
// No checks are made for invalid memory locations or that the
// end address is > then the first start address.

void MemCopy(Uint16 *SourceAddr, Uint16* SourceEndAddr, Uint16* DestAddr)
{
    while(SourceAddr < SourceEndAddr)
    { 
       *DestAddr++ = *SourceAddr++;
    }
    return;
}
	
//===========================================================================
// End of file.
//===========================================================================

here is the SPI setup

 

void spi_init() {

	EALLOW;   // This is needed to write to EALLOW protected registers

	///  SPIA GPIO //////
	/* Configure SPI-A pins using GPIO regs*/
   // This specifies which of the possible GPIO pins will be SPI functional pins.
	GpioCtrlRegs.GPAMUX2.bit.LCD_MISO_PIN = 1; // Configure GPIO16 as SPISIMOA
	GpioCtrlRegs.GPAMUX2.bit.LCD_MOSI_PIN = 1; // Configure GPIO17 as SPISOMIA
	GpioCtrlRegs.GPAMUX2.bit.LCD_SCLK_PIN = 1; // Configure GPIO18 as SPICLKA
	GpioCtrlRegs.GPAMUX2.bit.SPISTE_PIN = 1; // Configure GPIO19 as SPISTEA

	/* Disable internal pull-up for the selected pins */
	// Pull-ups can be enabled = 0 or disabled = 1 by the user.
	GpioCtrlRegs.GPAPUD.bit.LCD_MISO_PIN = 1; // Disable pull-up on GPIO16 (SPISIMOA) 0 = pull up
	GpioCtrlRegs.GPAPUD.bit.LCD_MOSI_PIN = 1; // Disable pull-up on GPIO17 (SPISOMIA)
	GpioCtrlRegs.GPAPUD.bit.LCD_SCLK_PIN = 1; // Disable pull-up on GPIO18 (SPICLKA)
	GpioCtrlRegs.GPAPUD.bit.SPISTE_PIN = 1; // Disable pull-up on GPIO19 (SPISTEA)

	/* Set qualification for selected pins to asynch only */
	// This will select asynch (no qualification) for the selected pins.
	GpioCtrlRegs.GPAQSEL2.bit.LCD_MISO_PIN = 3; // Asynch  GPIO16 (SPISIMOA)
	GpioCtrlRegs.GPAQSEL2.bit.LCD_MOSI_PIN = 3; // Asynch  GPIO17 (SPISOMIA)
	GpioCtrlRegs.GPAQSEL2.bit.LCD_SCLK_PIN = 3; // Asynch  GPIO18 (SPICLKA)
	GpioCtrlRegs.GPAQSEL2.bit.SPISTE_PIN = 3; // Asynch  GPIO19 (SPISTEA)

	SpiaRegs.SPICCR.bit.SPISWRESET = 0; // Reset SPI

	//SpiaRegs.SPICCR.all=0x001F;         //16-bit character, Loopback mode
	SpiaRegs.SPICCR.all = 0x0047;           //8-bit character, clock polarity normal  output falling input rising
	//SpiaRegs.SPICTL.all=0x0017;           //overrun interrupt and Interrupt enabled, Master/Slave XMIT enabled
	SpiaRegs.SPICTL.all = 0x0007;           //Interrupt enabled, Master mode, XMIT (TALK) enabled
	SpiaRegs.SPISTS.all = 0x0000;           // Interrupts and buffers cleared
	//SpiaRegs.SPIBRR=0x0063;                 // Baud rate
	SpiaRegs.SPIBRR = 0x0000;                 // Baud rate
	//SpiaRegs.SPIFFTX.all=0xC022;             // Enable FIFO's, set TX FIFO level to 4
	//SpiaRegs.SPIFFTX.bit.SPIRST=1;
	//SpiaRegs.SPIFFTX.all = 0x0000;           // No FIFO
	//SpiaRegs.SPIFFRX.all=0x0022;             // Set RX FIFO level to 4
	//SpiaRegs.SPIFFRX.all = 0x0000;           // No FIFO

	//SpiaRegs.SPIFFCT.all = 0x00;        // transmit delay

	SpiaRegs.SPIPRI.all = 0x0010; // free run , SPISTE inversion bit = normal active low
	//SpiaRegs.SPIPRI.all = 0x0020; // soft select , SPISTE inversion bit normal active low

	SpiaRegs.SPICCR.bit.SPISWRESET = 1;  // Enable SPI

	 //SpiaRegs.SPIFFTX.bit.TXFIFO=1;
	// SpiaRegs.SPIFFRX.bit.RXFIFORESET=1;

	EDIS; // This is needed to disable write access to EALLOW protected registers

}

 

 

Something else that is very strange is that to set GPIO 34 high or low it is backwards from the other GPIOs that I have tested

Ive tested GPIO's 00,1,5,6,7,34 for this application. wierd!!!!

 

Any comments are appreciated.

 

thanks

Tim

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...