This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

tiva uart 数据输出



刚接触tiva版 不会用特此请教

思路:用tiva ADC采样数据 再通过uart3输出。

目的:得到ADC采样数据的txt文件用于其他软件分析。

注:uartcharput只能输出到uart,查资料有说再用vs读取串口输出txt文件,ccs本身

不能输出txt。

下面是我的code能从示波器看到uart3口的输出波形,但我不知道输出的具体是什么

请高手指点

int main(void)

{
//channel 0
uint32_t ui32ADC0Value[8];
volatile uint32_t ui32ADCAvg_PE1;
volatile uint32_t ui32ADCAvg_PE2;
volatile uint32_t ui32ADCValueF_PE1;
volatile uint32_t ui32ADCValueF_PE2;

SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);
//Setup ADC Port PE1, PE2
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
////////////////////////////
//Enable UART

SysCtlPeripheralEnable(SYSCTL_PERIPH_UART3);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
// HWREG(GPIO_PORTD_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY_DD;
// HWREG(GPIO_PORTD_BASE + GPIO_O_CR) = 0x80;


GPIOPinConfigure(GPIO_PC7_U3TX);
GPIOPinTypeUART(GPIO_PORTC_BASE, GPIO_PIN_7);
UARTConfigSetExpClk(UART3_BASE, SysCtlClockGet(), 115200,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));
UARTEnable(UART3_BASE);

while(1){

while(!ADCIntStatus(ADC0_BASE, 0, false))
{
}
ADCSequenceDataGet(ADC0_BASE, 0, ui32ADC0Value);

//channel 0
ui32ADCAvg_PE1 = (ui32ADC0Value[0] + ui32ADC0Value[1] + ui32ADC0Value[2] + ui32ADC0Value[3] + 2)/4;
ui32ADCValueF_PE1 = ((1000*ui32ADCAvg_PE1)-1580)/23/1000;

UARTCharPut(UART3_BASE, ui32ADCValueF_PE1/10000+'0');
UARTCharPut(UART3_BASE, ui32ADCValueF_PE1%10000/1000+'0');
UARTCharPut(UART3_BASE, ui32ADCValueF_PE1%1000/100+'0');
UARTCharPut(UART3_BASE, ui32ADCValueF_PE1%100/10+'0');
UARTCharPut(UART3_BASE, ui32ADCValueF_PE1%10+'0');

//channel 1
ui32ADCAvg_PE2 = (ui32ADC0Value[4] + ui32ADC0Value[5] + ui32ADC0Value[6] + ui32ADC0Value[7] + 2)/4;
ui32ADCValueF_PE2 = ((1000*ui32ADCAvg_PE2)-1580)/23/1000;

UARTCharPut(UART3_BASE, ui32ADCValueF_PE2/10000+'0');//MSD
UARTCharPut(UART3_BASE, ui32ADCValueF_PE2%10000/1000+'0');
UARTCharPut(UART3_BASE, ui32ADCValueF_PE2%1000/100+'0');
UARTCharPut(UART3_BASE, ui32ADCValueF_PE2%100/10+'0');
UARTCharPut(UART3_BASE, ui32ADCValueF_PE2%10+'0');//LSD

问题:①怎样输出采样数据的txt文件?

            ②参考代码

UARTCharPut(UART3_BASE, ui32ADCValueF_PE1/10000+'0');
UARTCharPut(UART3_BASE, ui32ADCValueF_PE1%10000/1000+'0');
UARTCharPut(UART3_BASE, ui32ADCValueF_PE1%1000/100+'0');
UARTCharPut(UART3_BASE, ui32ADCValueF_PE1%100/10+'0');
UARTCharPut(UART3_BASE, ui32ADCValueF_PE1%10+'0');

此段代码的作用是什么?

③有两个ADC的采样数据,该怎么输出?