[TM4C123 single-chip microcomputer practice] configure SSI and drive DAC7811 to display a sine wave,
I have learned TM4C123 single-chip in the electric competition over the past few days. In general, combined with the official routine and reference manual, a good oscilloscope will be much more efficient.
TI's SSI is actually SPI.
First, familiarize yourself with SPI.
SPI is used to transmit data between the host and the slave through TX and RX. The communication between the host and the slave is activated through the CS chip selection signal line, and the frequency is controlled through the CLK clock signal.
# Include <stdbool. h> # include <stdint. h> # include "inc/hw_memmap.h" # include "driverlib/gpio. h "# include" driverlib/pin_map.h "# include" driverlib/ssi. h "# include" driverlib/sysctl. h "// ssi. h must have
Extern uint32_t Fre; void ssi_0 (void) {SysCtlClockSet (feature | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_10MHZ); // select the clock source
SysCtlPeripheralEnable (SYSCTL_PERIPH_SSI0); // enable SSI0
SysCtlPeripheralEnable (SYSCTL_PERIPH_GPIOA); // enable GPIO GPIOPinConfigure (Enabled); // enable the GPIO pin function GPIOPinConfigure (Enabled );
<P> </p> SysCtlGPIOAHBEnable (GPIO_PORTA_BASE); // mount the high-speed Peripheral Bus GPIOPinTypeSSI (GPIO_PORTA_BASE, GPIO_PIN_5 | GPIO_PIN_3 | GPIO_PIN_2 ); // enable the gpio ssi function SSIConfigSetExpClk (SSI0_BASE, SysCtlClockGet (), SSI_FRF_TI, SSI_MODE_MASTER, Fre, 16); // select the SSI clock source, select the working mode, select the frequency, select the number of sending digits
SSIEnable (SSI0_BASE); // enable} void DAC_Write_0 (uint16_t ssi0_send) {SSIDataPut (SSI0_BASE, 0x3FFF & ssi0_send ); /** // send data // while (SSIBusy (SSI0_BASE ));}
Pin selection:
We can refer to reference
About work mode selection:
SPI has four working modes:
We need to select based on the specific DAC receiving method:
Reference