1.头文件和变量定义(不是很清楚)
#include "driverlib/ssi.h"
#include "driverlib/i2c.h"
#include "driverlib/udma.h"
#include "driverlib/fpu.h"
#include "driverlib/rom.h"
#include "inc/hw_ssi.h"
#include "inc/hw_i2c.h"
2.初始化
// refer to teacher's demo, SSI module init
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1);
GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_1,<<); SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI1);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
GPIOPinConfigure(GPIO_PD0_SSI1CLK);
GPIOPinConfigure(GPIO_PD3_SSI1TX);
GPIOPinTypeSSI(GPIO_PORTD_BASE,GPIO_PIN_3|GPIO_PIN_0);
SSIConfigSetExpClk(SSI1_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_1, SSI_MODE_MASTER, , );
SSIEnable(SSI1_BASE);
3.波形数据生成(matlab)
clear all,clc
i=:
y=/*i;
y=ceil(y);
max(y)
min(y)
dec2hex(y)
4.写一个字
// write data
void dac_writedata(uint16_t ui32Data)
{
GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_1,<<);
SSIDataPut(SSI1_BASE, ui32Data);
while(SSIBusy(SSI1_BASE))
;
GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_1,<<);
}
5.调用示例
if (flag_wave==)
{
//dac_writedata(sin_data[i]/voltage_div);
dac_writedata(sin_data[i]/(/voltage));
}
6.改变定时器频率
TimerLoadSet(TIMER0_BASE, TIMER_A, SysCtlClockGet() / (freq*point) - ); // Change the timer0 frequency