Reply by vickykulkarni January 24, 20062006-01-24
Thanks, i figured it out. Works fine now.

>On Mon, 23 Jan 2006 20:35:08 -0600, "vickykulkarni" ><vickykulkarni@hotmail.com> wrote in comp.dsp: > >> Hi >> >> I am trying to use a GPIO pin as a trigger to switch the DSP
operations.
>> The gpio pin input is a pulse toggling betweeen 0 & 1. I want to set
the
>> dsp such that it performs certain operations when pulse is 0 & other >> operations when pulse is 1. I am inserting a part of my code. When the >> pulse is 0 i want to store the ADC samples in a buffer. I cant figure
out
>> what is wrong. The code seems to detect the pulse properly, but is not >> sampling the input. Any help is highly appreciated. Thanks in advance >> >> #include "DSP281x_Device.h" // DSP281x Headerfile Include File >> #include "DSP281x_Examples.h" // DSP281x Examples Include File >> #define ADC_MODCLK 0x3 >> #define ADC_CKPS 0x0 >> #define ADC_SHCLK 0xa >> #define SIZE 512 >> >> // Global variable for this example >> void Gpio_select(void); >> void Gpio_config(void); >> Uint16 I[SIZE]; >> Uint16 Q[SIZE]; >> main() >> { >> Uint16 i=0; >> Uint16 j=0; >> >> // Step 1. Initialize System Control: >> // PLL, WatchDog, enable Peripheral Clocks >> // This example function is found in the DSP281x_SysCtrl.c file. >> InitSysCtrl(); >> >> // Specific clock setting for this example: >> EALLOW; >> SysCtrlRegs.HISPCP.all = ADC_MODCLK; // HSPCLK =
SYSCLKOUT/ADC_MODCLK
>> EDIS; >> >> // Step 2. Initialize GPIO: >> // This example function is found in the DSP281x_Gpio.c file and >> // illustrates how to set the GPIO to it's default state. >> // InitGpio(); // Skipped for this example >> Gpio_select(); >> Gpio_config(); > >Am I completely missing something? You call the function >Gpio_config() which NEVER returns? > > [snip] > >> void Gpio_config(void) >> { >> while(1) >> {
GpioDataRegs.GPGDAT.bit.GPIOG5=GpioDataRegs.GPGDAT.bit.GPIOG4;
>> >> } >> } > >Nothing in main() after the call to Gpio_config() is ever going to >execute. > >-- >Jack Klein >Home: http://JK-Technology.Com >FAQs for >comp.lang.c http://c-faq.com/ >comp.lang.c++ http://www.parashift.com/c++-faq-lite/ >alt.comp.lang.learn.c-c++ >http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html >
Reply by Jack Klein January 24, 20062006-01-24
On Mon, 23 Jan 2006 20:35:08 -0600, "vickykulkarni"
<vickykulkarni@hotmail.com> wrote in comp.dsp:

> Hi > > I am trying to use a GPIO pin as a trigger to switch the DSP operations. > The gpio pin input is a pulse toggling betweeen 0 & 1. I want to set the > dsp such that it performs certain operations when pulse is 0 & other > operations when pulse is 1. I am inserting a part of my code. When the > pulse is 0 i want to store the ADC samples in a buffer. I cant figure out > what is wrong. The code seems to detect the pulse properly, but is not > sampling the input. Any help is highly appreciated. Thanks in advance > > #include "DSP281x_Device.h" // DSP281x Headerfile Include File > #include "DSP281x_Examples.h" // DSP281x Examples Include File > #define ADC_MODCLK 0x3 > #define ADC_CKPS 0x0 > #define ADC_SHCLK 0xa > #define SIZE 512 > > // Global variable for this example > void Gpio_select(void); > void Gpio_config(void); > Uint16 I[SIZE]; > Uint16 Q[SIZE]; > main() > { > Uint16 i=0; > Uint16 j=0; > > // Step 1. Initialize System Control: > // PLL, WatchDog, enable Peripheral Clocks > // This example function is found in the DSP281x_SysCtrl.c file. > InitSysCtrl(); > > // Specific clock setting for this example: > EALLOW; > SysCtrlRegs.HISPCP.all = ADC_MODCLK; // HSPCLK = SYSCLKOUT/ADC_MODCLK > EDIS; > > // Step 2. Initialize GPIO: > // This example function is found in the DSP281x_Gpio.c file and > // illustrates how to set the GPIO to it's default state. > // InitGpio(); // Skipped for this example > Gpio_select(); > Gpio_config();
Am I completely missing something? You call the function Gpio_config() which NEVER returns? [snip]
> void Gpio_config(void) > { > while(1) > { GpioDataRegs.GPGDAT.bit.GPIOG5=GpioDataRegs.GPGDAT.bit.GPIOG4; > > } > }
Nothing in main() after the call to Gpio_config() is ever going to execute. -- Jack Klein Home: http://JK-Technology.Com FAQs for comp.lang.c http://c-faq.com/ comp.lang.c++ http://www.parashift.com/c++-faq-lite/ alt.comp.lang.learn.c-c++ http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html
Reply by vickykulkarni January 23, 20062006-01-23
Hi

I am trying to use a GPIO pin as a trigger to switch the DSP operations.
The gpio pin input is a pulse toggling betweeen 0 & 1. I want to set the
dsp such that it performs certain operations when pulse is 0 & other
operations when pulse is 1. I am inserting a part of my code. When the
pulse is 0 i want to store the ADC samples in a buffer. I cant figure out
what is wrong. The code seems to detect the pulse properly, but is not
sampling the input. Any help is highly appreciated. Thanks in advance

#include "DSP281x_Device.h"     // DSP281x Headerfile Include File
#include "DSP281x_Examples.h"   // DSP281x Examples Include File
#define ADC_MODCLK 0x3  
#define ADC_CKPS   0x0   
#define ADC_SHCLK  0xa   
#define SIZE   512  

// Global variable for this example
void Gpio_select(void);
void Gpio_config(void);
Uint16 I[SIZE];
Uint16 Q[SIZE];  
main() 
{
   Uint16 i=0;
   Uint16 j=0;                     

// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the DSP281x_SysCtrl.c file.
   InitSysCtrl();
      
// Specific clock setting for this example:      
   EALLOW;
   SysCtrlRegs.HISPCP.all = ADC_MODCLK;	// HSPCLK = SYSCLKOUT/ADC_MODCLK
   EDIS;

// Step 2. Initialize GPIO: 
// This example function is found in the DSP281x_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
// InitGpio();  // Skipped for this example  
   Gpio_select();
   Gpio_config();
// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interrupts 
   DINT;

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

// Step 4. Initialize all the Device Peripherals:
// This function is found in DSP281x_InitPeripherals.c
// InitPeripherals(); // Not required for this example
   InitAdc();         // For this example, init the ADC

// Specific ADC setup for this example:
   AdcRegs.ADCTRL1.bit.ACQ_PS = ADC_SHCLK;  // Sequential mode
   AdcRegs.ADCTRL3.bit.ADCCLKPS = ADC_CKPS;     
   AdcRegs.ADCTRL1.bit.SEQ_CASC = 1;        // 1  Cascaded mode
   AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x0;
   AdcRegs.ADCTRL1.bit.CONT_RUN = 1;       // Setup continuous run
   AdcRegs.ADCTRL1.bit.SEQ_OVRD = 1;       // Enable Sequencer override
fe
   AdcRegs.ADCCHSELSEQ1.all = 0x3232;         // 
   AdcRegs.ADCCHSELSEQ2.all = 0x3232;
   AdcRegs.ADCCHSELSEQ3.all = 0x3232;
   AdcRegs.ADCCHSELSEQ4.all = 0x3232;
   AdcRegs.ADCMAXCONV.bit.MAX_CONV1 = 0x7;  // 
// Step 5. User specific code, enable interrupts:
// Start SEQ1
   AdcRegs.ADCTRL2.all = 0x2000;
   while(1)
   {  
       while (AdcRegs.ADCST.bit.INT_SEQ1== 0){}
       AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1;

   if (GpioDataRegs.GPGDAT.bit.GPIOG4==0)
{
       I[i++]= ( (AdcRegs.ADCRESULT0)>>4);
       Q[j++]= ( (AdcRegs.ADCRESULT1)>>4);
       I[i++]= ( (AdcRegs.ADCRESULT2)>>4);
       Q[j++]= ( (AdcRegs.ADCRESULT3)>>4);
       I[i++]= ( (AdcRegs.ADCRESULT4)>>4);
       Q[j++]= ( (AdcRegs.ADCRESULT5)>>4);
       I[i++]= ( (AdcRegs.ADCRESULT6)>>4);
       Q[j++]= ( (AdcRegs.ADCRESULT7)>>4);
}
    
       while (AdcRegs.ADCST.bit.INT_SEQ1== 0){}
       AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1;
	
   if (GpioDataRegs.GPGDAT.bit.GPIOG4==0)
{
       I[i++]= ( (AdcRegs.ADCRESULT8)>>4);
       Q[j++]= ( (AdcRegs.ADCRESULT9)>>4);              
       I[i++]= ( (AdcRegs.ADCRESULT10)>>4);              
       Q[j++]= ( (AdcRegs.ADCRESULT11)>>4);              
       I[i++]= ( (AdcRegs.ADCRESULT12)>>4);              
       Q[j++]= ( (AdcRegs.ADCRESULT13)>>4);              
       I[i++]= ( (AdcRegs.ADCRESULT14)>>4);              
       Q[j++]= ( (AdcRegs.ADCRESULT15)>>4);
}	              
       
	 if (i>511)
		{
			i=0;
		}
	 if (j>511)
		{
			j=0;
		}                                  
    }
}

void Gpio_select(void)
{
    Uint16 var1;

    var1= 0x0000;		// sets GPIO Muxs as I/O values
   
    EALLOW;

    GpioMuxRegs.GPGMUX.all=var1;

    GpioMuxRegs.GPGDIR.all=0xFFEF;//g4 i/p & g5 o/p
 
    EDIS;    
} 

  void Gpio_config(void) 
  {
   while(1)
   {    	 GpioDataRegs.GPGDAT.bit.GPIOG5=GpioDataRegs.GPGDAT.bit.GPIOG4;
	
       }	
}