嗨、大家好、我在通过 SPC 从外部 ADC 读取数据时遇到问题、似乎找不到问题。 此时、我不断地从 ADC 接收0。 我使用的 ADC 是 MAX11060 (https://datasheets.maximintegrated.com/en/ds/MAX11040K-MAX11060.pdf)、我不确定是什么问题、我在下面列出了我的所有代码。
谢谢你
#include #include #include #include #include #include include "inc/hw_memmap.h" #include "inc/hw_types.h" #include "driverlib/adc.h" #include "driverlib/podec.h" #include "driverlib/fpu.h" #include "driverlib/gpio.h" #include "driverlib/driver.h"#include "driverlib/moverview.h"#include "driverlib.包含"driverlib/mvoltex"driver.h"#包含"driverlib/mov.h"#包含"driverib/driverlib.hr.ide"#driver.h"#包含"driverlib#driverlib#driverlib.inc"#driver.h"#driverlib.intrintrl.ide"#包含"driver.h"#driver.h/driverlib#driver.h/driverlib#driverlib#include "driver.h"#包含"driverlib#driverlib#driver.h"#包含"driverlib#driverlib#driver.h/driverlib#driverlib#driver.h" #包含"driverlib#driv //variable DECLARTATIONS //============================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================ ================================================================================================================================================================================================================SSI_DATA 2 uint32_t ui32Loop、ui32Index; uint32_t pui32DataTx[NUM_SSI_DATA] ; ================================================================================================================================================================================================================================================================================================================================================================================================================== #define UART_BAUD_RATE 115200 void ConfigureUART (void){ /*启用 UART 使用的 GPIO 外设*/ ROM_SysCtlPeripheralEnable (SYSCTL_Periph_GPIOA); /*启用 UART0 */ ROM_SysCtlPeripheralEnable (SYSCTL_Periph_UART0); /*为 UART 模式配置 GPI 引脚*/ ROM_GPIOPinConfigure (GPIO_PA0_U0RX); ROM_GPIOPinConfigure (GPIO_PA1_U0TX); ROM_GPIOPinTypeUART (GPIO_Porta_base、GPIO_PIN_0 | GPIO_PIN_1); /*使用内部16MHz 振荡器作为 UART 时钟源*/ UARTClockSourceSet (UART0_BASE、UART_CLOCK_PIOSC); ROM_UARTConfigSetExpClk (UART0_BASE、ROM_SysCtlClockGet ()、 UART_BAUD_RATE、(UART_CONFIG_WLEN_8 | UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_ONE)); /*初始化控制台 I/O 的 UART */ UARTStdioConfig (0、UART_BAUD_RATE、16000000); /*启用 UART 中断*/ ROM_IntMasterEnable(); ROM_UARTIntClear (UART0_BASE、ROM_UARTIntStatus (UART0_BASE、false)); ROM_UARTIntEnable (UART0_BASE、UART_INT_RX | UART_INT_RT); ROM_IntEnable (INT_UART0); } void SPIWrite (uint32_t Addr、uint32_t Val){ while (SSIDataGetNonBlocking (SSI2_base、&pui32DataRx[0])){} pui32DataTx[0]= Addr;pui32DataVal;pui32DataTx[1]、SSSi32DataRx[0]、sudr[SSuatt_base] (s=SSDaId=puattx、SIDt_puattx (SSuattx) pui32DataTx[1]); while (SSIBusy (SSI2_base)){} void SPIRead (uint32_t Addr){ while (SSIDataGetNonBlocking (SSI2_base、&pui32DataRx[0])){} SSIDataPut (SSI2_base、(SSI2_base)、[SSI2_daId] ;[SSI2_daDataRx0]; while (SSIBusy (SSI2_base)){} UARTprintf ("\n 接收到的数据:%i "、pui32DataRx[0]); } void main (void){ ROM_FULazyStackingEnable (); //将计时设置为直接从晶体运行。 SysCtlClockSet (SYSCTL_SYSDIV_8 | SYSCTL_USE_PLL | SYSCTAL_16MHz | SYSCTL_OSC_MAIN); ConfigureUART ();//函数用于初始化 UART 协议 外设使能(SYSCTL_Periph_SSI2); SysCtl_SysTHRIST_SSIPBLOCK (SSIPB_SSIP2);SysCtl_SSIPB_S (SSIPB_SSIPB_S) GPIOPinConfigure (GPIO_PB4_SSI2CLK); GPIOPinConfigure (GPIO_PB5_SSI2FSS); GPIOPinConfigure (GPIO_PB6_SSI2RX); GPIOPinConfigure (GPIO_PB7_SSI2TX); GPIOPinTypeSSI (GPIO_PORTB_BASE、 GPIO_PIN_7 | GPIO_PIN_6 | GPIO_PIN_4); SSIConfigSetExpClk (SSI2_base、SysCtlClockGet ()、SSI_FRF_MOTO_MODE_0、 SSI_MODE_MASTER、1000000、8); GPIOPinTypeGPIOOutput (GPIO_PORTB_BASE、GPIO_PIN_5); GPIOPinWrite (GPIO_PORTB_BASE、GPIO_PIN_5、GPIO_PIN_5); SSIEnable (SSI2_base); SSIConfigSetExpClk (SSI2_base、 SysCtlClockGet ()、SSI_FRF_MOTO_MODE_0、 SSI_MODE_MASTER、1000000、8); SSIEnable (SSI2_base); GPIOPinWrite (GPIO_PORTB_BASE、 GPIO_PIN_5、0); SPIWrite (0x60、0x34); //SPIWrite (0x60、0xF0); SPIRead (0xE0); GPIOPinWrite (GPIO_PORTB_BASE、GPIO_PIN_5、GPIO_PIN_5); SSIDisable (SSI2_base); UARTprintf ("\n 程序编码..."); }