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,1<<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, 10000000, 16);
    SSIEnable(SSI1_BASE);

3.波形数据生成(matlab)

clear all,clc
i=0:12
y=4095/12*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,0<<1);
    SSIDataPut(SSI1_BASE, ui32Data);
    while(SSIBusy(SSI1_BASE))
        ;
    GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_1,1<<1);
}

5.调用示例

if (flag_wave==0)
    {
     //dac_writedata(sin_data[i]/voltage_div);
        dac_writedata(sin_data[i]/(3300/voltage));
    }

6.改变定时器频率

TimerLoadSet(TIMER0_BASE, TIMER_A, SysCtlClockGet() / (freq*point) - 1);    // Change the timer0 frequency    

 

posted on 2015-12-23 16:37  planet  阅读(1305)  评论(0编辑  收藏  举报