工具/软件:Code Composer Studio
下午好!
我想知道、如果我使用 comand "sprintf"、我的 ADC 程序为什么会崩溃。 这是在没有 sprintf 的情况下运行我的程序的结果:
和终端:
所以一切看起来都很好。
好的、如果我使用 sprintf、现在是系统:
我在终端上看不到任何东西。
那么为什么这不起作用呢?
最近帮助的速度非常快、现在可能我找到了解决方案。
(抱歉我的英语、但 这不是我的母语、我只是在学习)
谢谢。
这是代码:
#include
#include
#include
#include
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include "driverlib/adc.h"
#include "driverlib/debug.h"
空 UARTPutString (char* stg);
字符表[10]="0\r";
int main (void){
uint32_t ui32ADC0Value[4];
volatile uint32_t ui32TempAvg;
volatile uint32_t ui32TempValueC;
volatile uint32_t ui32TempValueF;
SysCtlClockSet (SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHz);
SysCtlPeripheralEnable (SYSCTL_Periph_UART0);
SysCtlPeripheralEnable (SYSCTL_Periph_GPIOA);
SysCtlPeripheralEnable (SYSCTL_Periph_ADC0);
ADCHardwareOversampleConfigure (ADC0_BASE、64);
ADCSequenceConfigure (ADC0_BASE、1、ADC_TRIGGER_PROCESSOR、0);
ADCSequenceStepConfigure (ADC0_BASE、1、0、ADC_CTL_TS);
ADCSequenceStepConfigure (ADC0_BASE、1、1、ADC_CTL_TS);
ADCSequenceStepConfigure (ADC0_BASE、1、2、ADC_CTL_TS);
ADCSequenceStepConfigure (ADC0_BASE、1、3、ADC_CTL_TS|ADC_CTL_IE|ADC_CTL_END);
ADCSequenceEnable (ADC0_BASE、1);
GPIOPinConfigure (GPIO_PA0_U0RX);
GPIOPinConfigure (GPIO_PA1_U0TX);
GPIOPinTypeUART (GPIO_Porta_base、GPIO_PIN_0 | GPIO_PIN_1);
UARTConfigSetExpClk (UART0_BASE、SysCtlClockGet ()、115200、(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));
while (1)
{
ADCIntClear (ADC0_BASE、1);
ADCProcessorTrigger (ADC0_BASE、1);
while (!ADCIntStatus (ADC0_BASE、1、false))
{}
ADCSequenceDataGet (ADC0_BASE、1、ui32ADC0Value);
ui32TempAvg =(ui32ADC0Value[0]+ ui32ADC0Value[1]+ ui32ADC0Value[2]+ ui32ADC0Value[3]+ 2)/4;
ui32TempValueC =(1475 -(2475 * ui32TempAvg)/ 4096)/10;
ui32TempValueF =((ui32TempValueC * 9)+ 160)/5;
//sprintf (table、"%d "、ui32TempValueC); //------------------------------------ 我改变了这个短跑!!!!!!!!!!!
UARTPutString (table);
SysCtlDelay (2000000);
}
}
空 UARTPutString (char* stg)
{
int i;
int len = 0;
len = strlen (stg);
for (i=0;<len; i++)
UARTCharPut (UART0_BASE、stg[i]);
}


