📄 sindata.c
字号:
#include "DSP281x_Device.h" // DSP281x Headerfile Include File
#include "DSP281x_Examples.h" // DSP281x Examples Include File
#include "float.h"
#include "math.h"
volatile Uint16 angel_step,*Dataram=(Uint16*)0x100000;//RAM 起始地址为0X100000
volatile float sindata,angel; /*k代表角度*/
//延时
void main(void)
{
// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example 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();
angel_step=0;
while(1)
{if(Dataram<(Uint16*)0x107a13)//256K
{angel=180.0/31250*angel_step;
angel=3.1415926*angel;
angel=angel/180;/*数据类型优先级,sin弧度计算*/
sindata=sin(angel);
sindata=sindata*1024;
sindata=sindata+1024;
sindata=sindata*32;
if(sindata>=65536)
{*Dataram++=65535;
angel_step++;
}
else
{*Dataram++=sindata;
angel_step++;
}
}
else
asm(" nop");
}
}
//===========================================================================
// No more.
//=====
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -