⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 example_2833xda.c

📁 TMS32028335 的一些例程
💻 C
字号:
// TI File $Revision: /main/1 $
// Checkin $Date: August 29, 2007   14:07:44 $
//###########################################################################
//
// FILE:   Example_2833xDMA_XINTF_to_Ram.c
//
// TITLE:  DSP2833x DMA Ram to Ram
// ASSUMPTIONS:
//
//    This program requires the DSP2833x header files.
//
//    As supplied, this project is configured for "boot to SARAM"
//    operation.  The 2833x Boot Mode table is shown below.
//    For information on configuring the boot mode of an eZdsp,
//    please refer to the documentation included with the eZdsp,
//
//       $Boot_Table:
//
//         GPIO87   GPIO86     GPIO85   GPIO84
//          XA15     XA14       XA13     XA12
//           PU       PU         PU       PU
//        ==========================================
//            1        1          1        1    Jump to Flash
//            1        1          1        0    SCI-A boot
//            1        1          0        1    SPI-A boot
//            1        1          0        0    I2C-A boot
//            1        0          1        1    eCAN-A boot
//            1        0          1        0    McBSP-A boot
//            1        0          0        1    Jump to XINTF x16
//            1        0          0        0    Jump to XINTF x32
//            0        1          1        1    Jump to OTP
//            0        1          1        0    Parallel GPIO I/O boot
//            0        1          0        1    Parallel XINTF boot
//            0        1          0        0    Jump to SARAM	    <- "boot to SARAM"
//            0        0          1        1    Branch to check boot mode
//            0        0          1        0    Boot to flash, bypass ADC cal
//            0        0          0        1    Boot to SARAM, bypass ADC cal
//            0        0          0        0    Boot to SCI-A, bypass ADC cal
//                                              Boot_Table_End$
//
//
// DESCRIPTION:
//
// Code will perform a block copy of 1024 words from Zone 6 XINTF (DMABuf2) 
// to L4 SARAM (DMABuf1) .  
// Transfer will be started by Timer0.  
// We will use 32-bit DMA datasize.  Note this is independent from the XINTF
// data width which is x16. Code will end in local_DINTCH1_ISR once the transfer is 
// complete
//
// Watch Variables:
//      DMABuf1
//      DMABuf2
//
//###########################################################################
//
// Original source by: M.P.
//
// $TI Release: DSP2833x Header Files V1.01 $
// $Release Date: September 26, 2007 $
//###########################################################################

#include "DSP2833x_Device.h"     // DSP2833x Headerfile Include File
#include "DSP2833x_Examples.h"   // DSP2833x Examples Include File
#include <math.h>

#define DA_CHA		*(Uint16 *)0x4040
#define DA_CHB		*(Uint16 *)0x4041
#define DA_CHC		*(Uint16 *)0x4042
#define DA_CHD		*(Uint16 *)0x4043
#define DA_TRANS	*(Uint16 *)0x40E0

void main(void)
{
   Uint16 CHA_DATA = 0;
   Uint16 CHB_DATA = 0;
   Uint16 CHC_DATA = 0;
   Uint16 CHD_DATA = 0;
   Uint16 flagA = 0;
// 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 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();
//////DA TEST//////   
   InitXintf();
   while(1)
   {
	if(flagA)
	{
		CHA_DATA -= 100;
		if(CHA_DATA == 0)
		{
			flagA = 0;
		}
	}
	else
	{
		CHA_DATA += 100;
		if(CHA_DATA == 4000)
		{
			flagA = 1;
		}
	}

	if(flagA)
		CHB_DATA = 0;
	else
		CHB_DATA = 0xffff;

	if(CHC_DATA == 4000)
		CHC_DATA = 0;
	else
		CHC_DATA += 100;

	CHD_DATA = 2047 * sin((float)(2 * 3.14 * (float)CHC_DATA / 4000.0)) + 2048;

	DA_CHA = CHA_DATA;//三角波
	DA_CHB = CHB_DATA;//方波
	DA_CHC = CHC_DATA;//锯齿波
	DA_CHD = CHD_DATA;//正弦波
	DA_TRANS = 1;

	DELAY_US(1000);
   }
}



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -