#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_memmap.h"
#include "inc/hw_ssi.h"
#include "inc/hw_types.h"
#include "driverlib/ssi.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"
#include <stdbool.h>
#include "inc/hw_memmap.h"
#include "inc/hw_ssi.h"
#include "inc/hw_types.h"
#include "driverlib/ssi.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"
#define NUM_SSI_DATA 8
const uint8_t pui8DataTx[NUM_SSI_DATA] =
{0xFF, 0xF8, 0xF8, 0x88, 0x01, 0x1F, 0x1F, 0x01};
const uint8_t pui8DataTx[NUM_SSI_DATA] =
{0xFF, 0xF8, 0xF8, 0x88, 0x01, 0x1F, 0x1F, 0x01};
int main(void)
{
uint32_t ui32Index;
uint32_t ui32Data;
SysCtlClockSet(SYSCTL_SYSDIV_4|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI1);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
{
uint32_t ui32Index;
uint32_t ui32Data;
SysCtlClockSet(SYSCTL_SYSDIV_4|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI1);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
GPIOPinConfigure(GPIO_PD3_SSI1TX);
GPIOPinConfigure(GPIO_PD0_SSI1CLK);
//复用为外设引脚;
GPIOPinTypeSSI(GPIO_PORTD_BASE,GPIO_PIN_3);
GPIOPinTypeSSI(GPIO_PORTD_BASE,GPIO_PIN_0);
//设置为SSI功能
SSIConfigSetExpClk(SSI1_BASE,SysCtlClockGet(),SSI_FRF_MOTO_MODE_1,SSI_MODE_MASTER,1000000,16);
//配置SSI1
SSIEnable(SSI1_BASE);
GPIOPinConfigure(GPIO_PD0_SSI1CLK);
//复用为外设引脚;
GPIOPinTypeSSI(GPIO_PORTD_BASE,GPIO_PIN_3);
GPIOPinTypeSSI(GPIO_PORTD_BASE,GPIO_PIN_0);
//设置为SSI功能
SSIConfigSetExpClk(SSI1_BASE,SysCtlClockGet(),SSI_FRF_MOTO_MODE_1,SSI_MODE_MASTER,1000000,16);
//配置SSI1
SSIEnable(SSI1_BASE);
GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_1,0);
SSIDataPut(SSI1_BASE,0xFFF);
while(SSIBusy(SSI1_BASE))
{
for(ui32Index = 0; ui32Index < NUM_SSI_DATA; ui32Index++)
{
ui32Data = pui8DataTx[ui32Index];
SSIDataPut(SSI0_BASE, ui32Data);
while(SSIBusy(SSI0_BASE))
{
}
SysCtlDelay(40000000);
}
}
}
while(SSIBusy(SSI1_BASE))
{
for(ui32Index = 0; ui32Index < NUM_SSI_DATA; ui32Index++)
{
ui32Data = pui8DataTx[ui32Index];
SSIDataPut(SSI0_BASE, ui32Data);
while(SSIBusy(SSI0_BASE))
{
}
SysCtlDelay(40000000);
}
}
}
Susan Yang:
有一些相关的DAC应用,您可以参考一下
arduining.com/…/
gist.github.com/…/27527bd9939bba5f1f2b7a3480c95d07
user5362661:
回复 Susan Yang:
好的,感谢
xyz549040622:
是不是需要经过一个三极管驱动呢,驱动电流好像不太够。