Пример #1
0
void init(void) {
	InitSysCtrl();

	EALLOW;
	//TODO Add code to configure GPADIR through IPC
	GPIO_WritePin(31, 1);
	GPIO_WritePin(34, 1);
	InitSysCtrl();
// 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 F2837xD_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 F2837xD_DefaultIsr.c.
// This function is found in F2837xD_PieVect.c.
	InitPieVectTable();

// Enable global Interrupts and higher priority real-time debug events:
	EINT;  // Enable Global interrupt INTM
	ERTM;  // Enable Global realtime interrupt DBGM

}
Пример #2
0
void InitHW(void)
{
	/* Step 1. Initialize System Control:                            */
	/* PLL, WatchDog, enable Peripheral Clocks                       */
	InitSysCtrl();
	// Step 2. 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 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.
     EALLOW;  // This is needed to write to EALLOW protected registers
//   PieVectTable.TINT0 = &cpu_timer0_isr;
//   PieVectTable.XINT13 = &cpu_timer1_isr;
	 PieVectTable.TINT2 = &os_time_tick;
     EDIS;    // This is needed to disable write to EALLOW protected registers
     // Step 3. Initialize the Device Peripheral. This function can be
	 //         found in DSP2833x_CpuTimers.c
    
}
Пример #3
0
void StartUp()
{
	memcpy(&RamfuncsRunStart, &RamfuncsLoadStart,  (unsigned long)&RamfuncsLoadSize);

	InitSysCtrl();

	InitGpio();
	DINT;

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

	//Initialize Flash
	//InitFlash();

	EINT;   // Enable Global interrupt INTM
	ERTM;   // Enable Global realtime interrupt DBGM

	EALLOW;
		Flash_CPUScaleFactor = SCALE_FACTOR;
		Flash_CallbackPtr = 0;
	EDIS;
}
Пример #4
0
void main(void)
{
	//------- INTERNAL INIT------------//
    InitSysCtrl();
    DINT; //Disable CPU interrupts
    InitPieCtrl();
    IER = 0x0000; //Disable CPU interrupts and clear all CPU interrupt flags:
    IFR = 0x0000;
    InitPieVectTable();
    //------- END INTERNAL INIT--------//

	InitPWM3();
	InitDACA();
	InitDACC();
	InitADC();

    //PLL 1PHASE//
    SPLL_1ph_F_init(50,((float)(1.0/200000.0F)), &spll1);
    SPLL_1ph_F_notch_coeff_update(((float)(1.0/50000.0F)), (float)(2*PI*50*2),(float)0.00001,(float)0.1, &spll1);

    while(1)
    {

    }
}
Пример #5
0
void main(void)
{ 

	InitSysCtrl();
	InitXintf();
	InitXintf16Gpio();
	ADInit();
	DINT;
	InitPieCtrl();
	IER = 0x0000;
	IFR = 0x0000;
	InitPieVectTable();
   EALLOW;  // This is needed to write to EALLOW protected registers
   PieVectTable.TINT0 = &ISRTimer0;
   EDIS;    // This is needed to disable write to EALLOW protected registers
   InitCpuTimers();   // For this example, only initialize the Cpu Timers
   ConfigCpuTimer(&CpuTimer0, 100, 987); //在定时器内进行采样,采样率1.5KHz
	
    IER |= M_INT1;
    PieCtrlRegs.PIECTRL.bit.ENPIE = 1;
    PieCtrlRegs.PIEIER1.bit.INTx7 = 1; 
	EINT; 
	ERTM;  
/*EALLOW;
GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 0; // GPIO0 = GPIO0
GpioCtrlRegs.GPADIR.bit.GPIO0 = 1; 
EDIS;
GpioDataRegs.GPADAT.bit.GPIO0 = 0;*/
	SET_ADRST;  
	DELAY_US(100000);
	CLEAR_ADRST; 
	StartCpuTimer0();
	while(1);

}
Пример #6
0
void cpuInit(void){
	InitSysCtrl();

	/* 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 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). */
	InitPieVectTable();

	/* Timer interrupt mapping */
	EALLOW;  /* This is needed to write to EALLOW protected registers */
	PieVectTable.TINT0 = &cpu_timer0_isr;
	EDIS;    /* This is needed to disable write to EALLOW protected registers */

	InitCpuTimers();

	/* Write the LPM code value */
	EALLOW;
	if (SysCtrlRegs.PLLSTS.bit.MCLKSTS != 1){ 	/* Only enter Idle mode when PLL is not in limp mode. */
		SysCtrlRegs.LPMCR0.bit.LPM = 0x0000;  	/* LPM mode = Idle - can be woken by timer interrupt */
	}

	/* Enable interrupts */
	EDIS;
}
void main(void)
{
//
// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the F2837xS_SysCtrl.c file.
//
    InitSysCtrl();

//
// Step 2. Initialize GPIO:
// This example function is found in the F2837xS_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
//
    InitGpio();

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

//
// Step 4. Call function to issue the SCC reset. If the SCC reset has
// already occurred, the program will stop here.
//
    if(CpuSysRegs.RESC.bit.SCCRESETn != 1)
    {
        IssueSCCReset(CPUTIMER0);
    }
    else
    {
        ESTOP0;
        for(;;);
    }
}
void main(void)
{
//--- CPU Initialization
    InitSysCtrl();                      // Initialize the CPU
    DINT;
    InitPieCtrl();                      // Initialize and enable the PIE
    IER = 0x0000;
    IFR = 0x0000;
    InitPieVectTable();
    EINT;                               // Enable Global interrupt INTM
    ERTM;                               // Enable Global realtime interrupt DBGM

// Complex multiply test
	x.dat[0]=2.0;						// x_re
	x.dat[1]=3.0;						// x_im
	w.dat[0]=4.0;						// w_re
	w.dat[1]=5.0;						// w_im
	y.dat[0]=0;
	y.dat[1]=0;
// Result is y = -7 + j*22

    asm(" NOP");
	y = mpy_SP_CSxCS(w,x);				// complex multiply
	asm(" NOP");

//--- Main Loop
	while(1)							// Dummy loop.  Wait for an interrupt.
	{
		asm(" NOP");
	}

} // end of main()
Пример #9
0
void main(void)
{
	
//--- CPU Initialization
    InitSysCtrl();                      // Initialize the CPU
    DINT;
    InitPieCtrl();                      // Initialize and enable the PIE
    IER = 0x0000;
    IFR = 0x0000;
    InitPieVectTable();
    EINT;                               // Enable Global interrupt INTM
    ERTM;                               // Enable Global realtime interrupt DBGM

// median() test
	memcpy_fast(x, y, N<<1);					// Start with same data
	z = 0.0;
	asm(" NOP");
	z = median_SP_RV(x, N);
	asm(" NOP");

// median_noreorder() test
	memcpy_fast(x, y, N<<1);					// Start with same data
	z = 0.0;
	asm(" NOP");
	z = median_noreorder_SP_RV(x, N);
	asm(" NOP");

//--- Main Loop
	while(1)							// Dummy loop.  Wait for an interrupt.
	{
		asm(" NOP");
	}

} // end of main()
Пример #10
0
void main()
{
    unsigned long i;

    InitSysCtrl();
    DINT;
    InitPieCtrl();
    IER = 0x0000;
    IFR = 0x0000;
    InitPieVectTable();
    EINT;   // Enable Global interrupt INTM
    ERTM;   // Enable Global realtime interrupt DBGM

    /* Signal Generator module initialisation   */
    sgen.offset=0;
    sgen.gain=0x7fff;        /* gain=1 in Q15                              */
    sgen.freq=5369;          /* freq = (Required Freq/Max Freq)*2^15       */
    /*      = (50/305.17)*2^15 = 5369             */
    sgen.step_max=1000;      /* Max Freq= (step_max * sampling freq)/65536 */
    /* Max Freq = (1000*20k)/65536 = 305.17       */
    sgen.phase=0x4000;       /* Phase= (required Phase)/180 in Q15 format  */
    /*      =  (+90/180) in Q15 = 4000h           */

    for(i=0; i<SIGNAL_LENGTH; i++)
    {
        ipcb1[i]=0;
        ipcb2[i]=0;
        ipcb3[i]=0;
        ipcb4[i]=0;
        ipcb5[i]=0;
        ipcb6[i]=0;
    }

    /*---------------------------------------------------------------------------
        Nothing running in the background at present
    ----------------------------------------------------------------------------*/


    for(i=0; i<SIGNAL_LENGTH; i++)
    {
        sgen.calc(&sgen);
        x11=sgen.out11;
        x12=sgen.out12;
        x13=sgen.out13;
        x21=sgen.out21;
        x22=sgen.out22;
        x23=sgen.out23;
        ipcb1[i]=x11;
        ipcb2[i]=x12;
        ipcb3[i]=x13;
        ipcb4[i]=x21;
        ipcb5[i]=x22;
        ipcb6[i]=x23;
    }

    for(;;);

} /* End: main() */
//
// Main
//
void main(void)
{
//
// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the F2837xS_SysCtrl.c file.
//
    InitSysCtrl();

//
// Step 2. 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 F2837xS_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 F2837xS_DefaultIsr.c.
// This function is found in F2837xS_PieVect.c.
//
    InitPieVectTable();

//
// Step 3. Configure the CLA memory spaces first followed by
// the CLA task vectors
//
    CLA_configClaMemory();
    CLA_initCpu1Cla1();

//
// Step 4. Enable global Interrupts and higher priority real-time debug events:
//
    EINT;  // Enable Global interrupt INTM
    ERTM;  // Enable Global realtime interrupt DBGM

//
// Step 5. Run the test
//
    CLA_runTest();
}
Пример #12
0
void main(void)
{
	InitSysCtrl();
// Copy time critical code and Flash setup code to RAM
// This includes the following ISR functions: epwm1_timer_isr(), epwm2_timer_isr()
// epwm3_timer_isr and and InitFlash();
// The  RamfuncsLoadStart, RamfuncsLoadEnd, and RamfuncsRunStart
// symbols are created by the linker. Refer to the F28335.cmd file.

// 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 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.
	EALLOW;  // This is needed to write to EALLOW protected registers
	PieVectTable.SEQ1INT = &PWM_AD_isr;
	PieVectTable.ECAN0INTA = &Skiip4_CAN_isr;
	EDIS;     // This is needed to disable write to EALLOW protected registers 
	
	InitFlash();
	MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart);
	MemCopy(&IQmathLoadStart, &IQmathLoadEnd, &IQmathRunStart);

	//ECan-A模块初始化
	InitECan();
	InitECan1();

	InitGpio();  // Skipped for this example 
	InitAdc();							// Initialize necessary ADC module, directly for SVPWM.
	InitEPwm();
  



	IER |= M_INT1; 
// Enable SEQ1_INT which is connected to PIE1.1:
    IER |= M_INT9;
// Enable eCAN0-A INT which is connected to PIE9.5:


	EINT;
} // end of main()
Пример #13
0
void main(void)
{

// Step 1. Initialize System Control registers, PLL, WatchDog, 
// peripheral Clocks to default state:
// This function is found in the DSP281x_SysCtrl.c file.
   InitSysCtrl();

// Step 2. Initalize 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  

// 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 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

// Step 5. User specific code 

   // Tests #1, #2, #3
   Gpio_PortA();
    
   // Test #4
   Gpio_PortB();
    
   // Test #5
   Gpio_PortF();

   program_stop();
    
// Step 6. IDLE loop. Just sit and loop forever (optional):    
//    for(;;);
     
}
Пример #14
0
void main(void)
{
// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the DSP280x_SysCtrl.c file.
	InitSysCtrl();
	
// Copy time critical code and Flash setup code to RAM
// The  RamfuncsLoadStart, RamfuncsLoadEnd, and RamfuncsRunStart
// symbols are created by the linker. Refer to the linker files. 
	MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart);

// Step 2. 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 DSP280x_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 DSP280x_DefaultIsr.c.
// This function is found in DSP280x_PieVect.c.
	InitPieVectTable();

// Step 3. Initialize the Device Peripherals:
	PMBusMaster_Init(I2C_SLAVE_ADDR, CLK_PRESCALE);

	EINT;

   // Application loop
	while(1)
	{
		//reads
		pass_fail = PMBusMaster(STATUS_TEMPERATURE, 1, 0, Temp);	//read byte
		pass_fail = PMBusMaster(OPERATION, 1, 0, Oprn);			//r/w byte (read)
		pass_fail = PMBusMaster(STATUS_WORD, 1, 0, Stat);		//read word
		pass_fail = PMBusMaster(VOUT_COMMAND, 1, 0, VCmd);		//r/w word (read)
		//writes
		pass_fail = PMBusMaster(STORE_DEFAULT_CODE, 0, 0xAA, 0);	//write byte
		pass_fail = PMBusMaster(OPERATION, 0, 0xBB, 0);			//r/w byte (write)				
		pass_fail = PMBusMaster(VOUT_COMMAND, 0, 0xCCDD, 0);		//r/w word (write)  
		
		Status = (Stat[1] << 8) | Stat[0];			//unpacking the two data bytes into one word
		Vout_Command = (VCmd[1] << 8) | VCmd[0];	//the lowest order byte is received first
	}
}   // end of main
Пример #15
0
void main(void)
{
// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the DSP2803x_SysCtrl.c file.
   InitSysCtrl();

// Step 2. Initialize GPIO:
// This example function is found in the DSP2803x_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 DSP2803x_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 DSP2803x_DefaultIsr.c.
// This function is found in DSP2803x_PieVect.c.
   InitPieVectTable();

// Step 4. Initialize all the Device Peripherals:
// Not required for this example

// Step 5. User specific code:

#if EXAMPLE1

    // This example is a basic pinout
    Gpio_setup1();

#endif  // - EXAMPLE1

#if EXAMPLE2

    // This example is a communications pinout
    Gpio_setup2();

#endif

}
Пример #16
0
void main(void)
{
	InitSysCtrl();
	InitSpiaGpio();
	Gpio_select();
	/*
	EALLOW;
	SysCtrlRegs.WDCR = 0x00AF; // re-enable the watchdog
	EDIS;
	 */
	DINT;
	IER = 0x0000;
	IFR = 0x0000;
	InitPieCtrl();
	InitPieVectTable();
	InitAdc();
	spi_fifo_init();
	Setup_ePWM();		// ePWM
	Setup_ADC();		// ADC setup
	EALLOW;	// This is needed to write to EALLOW protected registers
	PieVectTable.SPIRXINTA = &spiRxFifoIsr;
	PieVectTable.SPITXINTA = &spiTxFifoIsr;
	PieVectTable.SEQ1INT = &adc1_isr;
	PieVectTable.EPWM1_INT = &ePWM1A_compare_isr;
	EDIS;   // This is needed to disable write to EALLOW protected registers
	PieCtrlRegs.PIECTRL.bit.ENPIE = 1;   // Enable the PIE block
	PieCtrlRegs.PIEIER6.bit.INTx1 = 1;     // Enable PIE Group 6, INT 1
	PieCtrlRegs.PIEIER6.bit.INTx2 = 1;     // Enable PIE Group 6, INT 2
	PieCtrlRegs.PIEIER1.bit.INTx1 = 1;		 // adc1 (seq1 - pwm)
	PieCtrlRegs.PIEIER3.bit.INTx1 = 1;		 // epwm1
	IER |= 25;                            // Enable CPU INT6
	EINT;                                // Enable Global Interrupts
	ERTM;
	while (1)
	{
		if (AdcRegs.ADCST.bit.INT_SEQ1 == 1) // ADC seq1 interrupt for pwm (at prd)
		{


			flag1 = 1;
			AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1;

		}
		if (EPwm1Regs.ETFLG.bit.INT == 1)	// epwm interrupt for pwm of second converter (at prd)
		{


			flag2 = 1;
			EPwm1Regs.ETCLR.bit.INT = 1;
		}
	}
}
Пример #17
0
void main()
{
	initVariables();
	
	DINT;
	ms_delay(1);
	InitAdc();
	SetupAdc();
	InitSysCtrl();
	InitPieCtrl();
	IER = 0x0000;
	IFR = 0x0000;
	MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart);
	InitPieVectTable();
	easyDSP_SCI_Init();
	InitEPwm3();
	InitEPwm4();
	pwm_setup();
	initialize_mppt_timer();
	EALLOW;
	PieVectTable.TINT2 = &mppt_int;
	PieVectTable.EPWM3_INT = &pwm_int;
	PieCtrlRegs.PIEIER3.bit.INTx3 = 0x1;
	EDIS;
	IER |= M_INT3;
	IER |= M_INT14;
	EINT;
	ms_delay(1);
	InitEPwm3Gpio();
	//InitEPwm4Gpio();
//	EALLOW;
//	GpioCtrlRegs.GPADIR.bit.GPIO4 = 1;
//	GpioCtrlRegs.GPADIR.bit.GPIO5 = 1;
//	GpioCtrlRegs.GPADIR.bit.GPIO6 = 1;
//	GpioCtrlRegs.GPADIR.bit.GPIO7 = 1;
//
//	GpioDataRegs.GPASET.bit.GPIO4 = 1;
//	GpioDataRegs.GPASET.bit.GPIO5 = 1;
//	GpioDataRegs.GPACLEAR.bit.GPIO6 = 1;
//	GpioDataRegs.GPACLEAR.bit.GPIO7 = 1;
//	EDIS;
	ERTM;
	for(;;)
	{
////		Bus_Voltage_Q15 = ((long int) AdcResult.ADCRESULT1*VBUS_SCALE);
		if(delay_flag)
		{
			ms_delay(10000);
			delay_flag = 0;
		}
	}
}
Пример #18
0
void main(void){

   InitSysCtrl();
   DINT;
   InitPieCtrl();
   IER = 0x0000;
   IFR = 0x0000;
   InitPieVectTable();
   EALLOW;  // This is needed to write to EALLOW protected registers
   PieVectTable.TIMER0_INT = &cpu_timer0_isr;
   EDIS;    // This is needed to disable write to EALLOW protected registers
   InitCpuTimers();   // For this example, only initialize the Cpu Timers
   // 100MHz CPU Freq, 50 microsecond Period (in uSeconds) 20,000 Hz
   ConfigCpuTimer(&CpuTimer0, CPU_CLOCK_100, INT_PERIOD_uS);
   CpuTimer0Regs.TCR.all = 0x4001; // Use write-only instruction to set TSS bit = 0

   // Configure GPIO12 (LED rojo) as a GPIO output pin
   EALLOW;
   GpioCtrlRegs.GPAMUX1.bit.GPIO12 = 0; // declare GPIO
   GpioCtrlRegs.GPADIR.bit.GPIO12 = 1;  // decalre as output
   EDIS;

   // Enable CPU INT1 which is connected to CPU-Timer 0:
   IER |= M_INT1;
   // Enable TINT0 in the PIE: Group 1 __interrupt 7
   PieCtrlRegs.PIEIER1.bit.INTx7 = 1;

   //Configure the ADCs and power them up
   ConfigureADC();
   //Setup the ADCs for software conversions
   SetupADCSoftware();

   // Enable DACOUTA
   EALLOW;
   //Use VDAC as the reference for DAC
   DaccRegs.DACCTL.bit.DACREFSEL  = REFERENCE_VDAC;
   //Enable DAC output
   DaccRegs.DACOUTEN.bit.DACOUTEN = 1;
   EDIS;

// iniciar buffers de datos
   init_buffer();

// Enable global Interrupts and higher priority real-time debug events:
   EINT;   // Enable Global __interrupt INTM
   ERTM;   // Enable Global realtime __interrupt DBGM


// Step 6. IDLE loop. Just sit and loop forever (optional):
   for(;;);
}
Пример #19
0
void main()
{
	unsigned int i;
	
	//Initalize sys clocks and PIE table
	InitSysCtrl();
	DINT;
	InitPieCtrl();
	IER = 0x0000;
	IFR = 0x0000;
	InitPieVectTable();
	EINT;   // Enable Global interrupt INTM
	ERTM;   // Enable Global realtime interrupt DBGM   
	
	// Generate sample waveforms:
	Rad = 0.0f;
	   
	for(i=0; i < SIGNAL_LENGTH; i++)
    {
		sigIn[i]=0;
        sigOut[i]=0;
    }   
	
	/* FIR Generic Filter Initialisation    */ 
	firFP.order=FIR_ORDER; 
	firFP.dbuffer_ptr=dbuffer;
	firFP.coeff_ptr=(float *)coeff; 
	firFP.init(&firFP);
	
	
   	for(i=0; i < SIGNAL_LENGTH; i++)
  	{
  		xn=0.5*sin(Rad) + 0.5*sin(Rad2); //Q15
		sigIn[i]=xn;
        firFP.input= xn;
        firFP.calc(&firFP);
        yn = firFP.output;
        sigOut[i]=yn;
		Rad = Rad + RadStep;
		Rad2 = Rad2 + RadStep2;
   	}   
	
	while(1) 
	{
	
	}       

} /* End: main() */
Пример #20
0
void InitMicrocontroller(void)
{
	//copy InitFlash() to ram
	MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart);
	InitFlash();
	InitSysCtrl();	//calibrate ADC, enable peripheral clocks, etc.
	DINT; // Disable CPU interrupts
   	// Initialize PIE control registers to all PIE interrupts disabled and flags clear
   	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).
   	InitPieVectTable();
}
Пример #21
0
void main()
{    
	  unsigned long i;  
	  
  	  InitSysCtrl();
	  DINT;
	  InitPieCtrl();
	  IER = 0x0000;
	  IFR = 0x0000;
	  InitPieVectTable();
	  EINT;   // Enable Global interrupt INTM
	  ERTM;   // Enable Global realtime interrupt DBGM    
	  
/* Signal Generator module initialisation   */ 
      sgen.mode=1;              /* Set Mode bit for Continuous signal Generation  */            
      sgen.prescalar=1;         
      sgen.freq=5369;           /* freq = (Required Freq/Max Freq)*2^15           */
                                /*      = (50/305.17)*2^15 = 5369                 */    
      sgen.step_max=4000;       /* Max Freq= (step_max * sampling freq)/(4*65536) */
                                /* Max Freq = (4000*20k)/(4*65536) = 305.17       */
      sgen.gain=0x7fff;         /* ~1 in Q15 format                               */
      sgen.offset=0;
      sgen.t_rmpup=51;          /* 20% of T, 0.2 in Q8, 250 is 100%  */
      sgen.t_max=77;            /* 30% of T, 0.3 in Q8  			 */
      sgen.t_rmpdn=102;         /* 40% of T, 0.4 in Q8  			 */
      sgen.t_min=25;            /* 10% of T, 0.1 in Q8 				 */
      sgen.init(&sgen);
                
      for(i=0;i<SIGNAL_LENGTH;i++)
      {
        	ipcb[i]=0;
      } 
/*---------------------------------------------------------------------------
    Nothing running in the background at present           
----------------------------------------------------------------------------*/

       for(i=0;i<SIGNAL_LENGTH;i++)
       {
            sgen.calc(&sgen);
            x1=sgen.out;
            ipcb[i]=x1;
        } 
        
        for(;;);         

} /* End: main() */
void main(void)
{
//
// Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the F2837xS_SysCtrl.c file.
//
    InitSysCtrl();

//
// 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 F2837xS_PieCtrl.c file.
//
    InitPieCtrl();

//
// Clear all interrupts and initialize PIE vector table:
//
    IER = 0x0000;
    IFR = 0x0000;
    InitPieVectTable();

//
// Initialize random seed
//
    srand(time(NULL));

//
// Configure DAC
//
    configureDAC(DAC_NUM);

    while(1)
    {
        DAC_PTR[DAC_NUM]->DACVALS.all = (rand() % (high_limit-low_limit)) +
                                        low_limit;
        DELAY_US(1);
    }
}
Пример #23
0
void init_board ()
{
  DisableDog();
  EALLOW;
  SysCtrlRegs.PCLKCR0.bit.ADCENCLK = 1;/* Enable ADC peripheral clock*/
  (*Device_cal)();
  SysCtrlRegs.PCLKCR0.bit.ADCENCLK = 0;/* Return ADC clock to original state*/
  EDIS;

  /* Select Internal Oscillator 1 as Clock Source (default), and turn off all unused clocks to
   * conserve power.
   */
  IntOsc1Sel();

  /* Initialize the PLL control: PLLCR and DIVSEL
   * DSP28_PLLCR and DSP28_DIVSEL are defined in DSP2806x_Examples.h
   */
  InitPll(9,3);
  InitPeripheralClocks();
  EALLOW;

  /* Configure low speed peripheral clocks */
  SysCtrlRegs.LOSPCP.all = 0U;
  EDIS;

  /* Disable and clear all CPU interrupts */
  DINT;
  IER = 0x0000;
  IFR = 0x0000;
  InitPieCtrl();
  InitPieVectTable();
  InitCpuTimers();

  /* initial ePWM GPIO assignment... */
  config_ePWM_GPIO();

  /* initial GPIO qualification settings.... */
  EALLOW;
  GpioCtrlRegs.GPAQSEL1.all = 0x0;
  GpioCtrlRegs.GPAQSEL2.all = 0x0;
  GpioCtrlRegs.GPBQSEL1.all = 0x0;
  GpioCtrlRegs.GPBQSEL2.all = 0x0;
  EDIS;
}
Пример #24
0
void main(void)
{
// Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the DSP280x_SysCtrl.c file.
	InitSysCtrl();

// Copy time critical code and Flash setup code to RAM
// The  RamfuncsLoadStart, RamfuncsLoadEnd, and RamfuncsRunStart
// symbols are created by the linker. Refer to the linker files. 
	MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart);	

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

// Initialize all the Device Peripherals:
	PMBusSlave_Init(I2C_SLAVE_ADDR);

	EINT;

   // Application loop
	while(1)
	{
		PMBusSlave();	//respond to master commands
	}
}   // end of main
Пример #25
0
/**
 * Añadir descripcion de la funcion
 * @param void
 * @returns void
 */ 
void main(void)
{
	InitSysCtrl();
	DINT;
	InitGpioLED();
	InitPieCtrl();
	IER = 0x0000;
	IFR = 0x0000;
	InitPieVectTable();

	InitSO();

	/***** GUARDAMOS SP GLOBAL *****/
	asm(" MOV ACC,@SP ");
	asm(" MOV DP, #_PtrStack_Global");
	asm(" MOVL @_PtrStack_Global,ACC ");

	/***** ECHAMOS A CORRER EL SISTEMA OPERATIVO *****/
	OS_SCHEDULER();
}
Пример #26
0
void main()
{    
	   unsigned long i;
	   
  	   InitSysCtrl();
	   DINT;
	   InitPieCtrl();
	   IER = 0x0000;
	   IFR = 0x0000;
	   InitPieVectTable();
	   EINT;   // Enable Global interrupt INTM
	   ERTM;   // Enable Global realtime interrupt DBGM
	  
/* Signal Generator module initialisation   */ 
       rgen.offset=0;
       rgen.gain=0x7fff;        /* gain=1 in Q15                              */
       rgen.freq=5369;          /* freq = (Required Freq/Max Freq)*2^15       */
                                /*      = (50/305.17)*2^15 = 5369             */         
       rgen.step_max=1000;      /* Max Freq= (step_max * sampling freq)/65536 */
                                /* Max Freq = (1000*20k)/65536 = 305.17       */
       rgen.angle=8192;    /* phase_norm =(pi/4/(2*pi))*2^16=8192   */

        for(i=0;i<SIGNAL_LENGTH;i++)
        {
        	ipcb[i]=0;
        }              

/*---------------------------------------------------------------------------
    Nothing running in the background at present           
----------------------------------------------------------------------------*/

        for(i=0;i<SIGNAL_LENGTH;i++)
        {
            rgen.calc(&rgen);
            x1=rgen.out;
            ipcb[i]=x1;
        }       

		for(;;);

} /* End: main() */
void main(void)
{
//--- CPU Initialization
    InitSysCtrl();                      // Initialize the CPU
    DINT;
    InitPieCtrl();                      // Initialize and enable the PIE
    IER = 0x0000;
    IFR = 0x0000;
    InitPieVectTable();
    EINT;                               // Enable Global interrupt INTM
    ERTM;                               // Enable Global realtime interrupt DBGM


// Create some dummy test data
	x[0].dat[0] =  2.0;    				// x_re
	x[0].dat[1] =  3.0;					// x_im
    x[1].dat[0] = -1.0;                 // x_re
    x[1].dat[1] = -3.0;                 // x_im
    x[2].dat[0] = -4.3;                 // x_re
    x[2].dat[1] =  2.2;                 // x_im
    x[3].dat[0] =  7.3;                 // x_re
    x[3].dat[1] = -1.1;                 // x_im

// Inverse absolute value of a complex vector test
// Exected result: y = [0.2773501, 0.3162278, 0.2070345, 0.1354571]
    asm(" NOP");
	iabs_SP_CV(y, x, N);			 	// inverse complex absolute value
    asm(" NOP");

    asm(" NOP");
    iabs_SP_CV_2(y, x, N);              // inverse complex absolute value
    asm(" NOP");

//--- Main Loop
	while(1)							// Dummy loop.  Wait for an interrupt.
	{
		asm(" NOP");
	}

} // end of main()
Пример #28
0
void main()
{    
	   unsigned long i;

  	   InitSysCtrl();
	   DINT;
	   InitPieCtrl();
	   IER = 0x0000;
	   IFR = 0x0000;
	   InitPieVectTable();
	   EINT;   // Enable Global interrupt INTM
	   ERTM;   // Enable Global realtime interrupt DBGM
	     
/* Signal Generator module initialisation   */ 
       sgen.offset=0;
       sgen.gain=0x7fff;        /* gain=1 in Q15                              */
       sgen.freq=0x14F8CF92;    /* freq = (Required Freq/Max Freq)*2^31       */
                                /*      = (50/305.17)*2^31 = 0x14f8cf92       */         
       sgen.step_max=0x3E7FB26; /* Max Freq= (step_max * sampling freq)/2^32 */
                                /* Max Freq = (0x3E7FB26*20k)/2^32 = 305.17  */
       sgen.alpha=536870912;    		/* phase_norm =(pi/4/(2*pi))*2^16=8192   */
            
        for(i=0;i<SIGNAL_LENGTH;i++)
        {
        	ipcb[i]=0;
        }

        for(i=0;i<SIGNAL_LENGTH;i++)
        {
            sgen.calc(&sgen);
            x1=sgen.out;
            ipcb[i]=x1;
        }   
        
        for(;;);    

} /* End: main() */
Пример #29
0
/**
 * This function will initial TMS320F28379D board.
 */
void rt_hw_board_init()
{
    /* Configure the system clock @ 84 Mhz */
    InitSysCtrl();

    DINT;
    InitPieCtrl();

    IER = 0x0000;
    IFR = 0x0000;

    InitPieVectTable();

    EALLOW;  // This is needed to write to EALLOW protected registers
    PieVectTable.TIMER2_INT = &cpu_timer2_isr;
    PieVectTable.RTOS_INT = &RTOSINT_Handler;
    EDIS;

    InitCpuTimers();
    ConfigCpuTimer(&CpuTimer2, 200, 1000000 / RT_TICK_PER_SECOND);
    CpuTimer2Regs.TCR.all = 0x4000;
    IER |= M_INT14;

#ifdef RT_USING_HEAP
    rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
#endif

    rt_hw_sci_init();

#ifdef RT_USING_COMPONENTS_INIT
    rt_components_board_init();
#endif
#ifdef RT_USING_CONSOLE
    rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
#endif
    rt_interrupt_leave_sethook((void (*)(void))trap_rtosint);
}
Пример #30
0
void main(void)
{
// WARNING: Always ensure you call memcpy before running any functions from RAM
// InitSysCtrl includes a call to a RAM based function and without a call to
// memcpy first, the processor will go "into the weeds"
   #ifdef _FLASH
	memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize);
   #endif

// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the f2802x_SysCtrl.c file.
   InitSysCtrl();

// Step 2. Initialize GPIO:
// This example function is found in the f2802x_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
// InitGpio();  // Skipped for this example
// For this case, just init GPIO for EPwm1-EPwm4

// For this case just init GPIO pins for EPwm1, EPwm2, EPwm3, EPwm4
// These functions are in the f2802x_EPwm.c file
   InitEPwm1Gpio();
   InitEPwm2Gpio();
   InitEPwm3Gpio();
   InitEPwm4Gpio();

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

// Step 4. Initialize all the Device Peripherals:
// Not required for this example

// For this example, only initialize the EPwm
// Step 5. User specific code, enable interrupts:
   update =1;
   DutyFine =0;

   EALLOW;
   SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0;
   EDIS;

// Some useful Period vs Frequency values
//  SYSCLKOUT =     60 MHz       40 MHz
//  --------------------------------------
//	Period	        Frequency    Frequency
//	1000	        60 kHz       40 kHz
//	800		        75 kHz       50 kHz
//	600		        100 kHz      67 kHz
//	500		        120 kHz      80 kHz
//	250		        240 kHz      160 kHz
//	200		        300 kHz      200 kHz
//	100		        600 kHz      400 kHz
//	50		        1.2 Mhz      800 kHz
//	25		        2.4 Mhz      1.6 MHz
//	20		        3.0 Mhz      2.0 MHz
//	12		        5.0 MHz      3.3 MHz
//	10		        6.0 MHz      4.0 MHz
//	9		        6.7 MHz      4.4 MHz
//	8		        7.5 MHz      5.0 MHz
//	7		        8.6 MHz      5.7 MHz
//	6		        10.0 MHz     6.6 MHz
//	5		        12.0 MHz     8.0 MHz

//====================================================================
// ePWM and HRPWM register initialization
//====================================================================
   HRPWM1_Config(10);	    // ePWM1 target, Period = 10
   HRPWM2_Config(20);	    // ePWM2 target, Period = 20
   HRPWM3_Config(10);	    // ePWM3 target, Period = 10
   HRPWM4_Config(20);	    // ePWM4 target, Period = 20

   EALLOW;
   SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1;
   EDIS;

   while (update ==1)
   {
        for(DutyFine =1; DutyFine <256 ;DutyFine ++)
        {
            // Example, write to the HRPWM extension of CMPA
            EPwm1Regs.CMPA.half.CMPAHR = DutyFine << 8;     // Left shift by 8 to write into MSB bits
            EPwm2Regs.CMPA.half.CMPAHR = DutyFine << 8;     // Left shift by 8 to write into MSB bits

            // Example, 32-bit write to CMPA:CMPAHR
            EPwm3Regs.CMPA.all = ((Uint32)EPwm3Regs.CMPA.half.CMPA << 16) + (DutyFine << 8);
            EPwm4Regs.CMPA.all = ((Uint32)EPwm4Regs.CMPA.half.CMPA << 16) + (DutyFine << 8);

            for (i=0;i<10000;i++){}   // Dummy delay between MEP changes
		}
   }
}