TIVA C Launchpad的实例(周计划之第六周)
[复制链接]
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/adc.h"
#include "driverlib/gpio.h"
#include "driverlib/sysctl.h"
#include "utils/uartstdio.h"
void InitConsole(void)
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
GPIOPinConfigure(GPIO_PA0_U0RX);
GPIOPinConfigure(GPIO_PA1_U0TX);
GPIOPinTypeUART(GPIO_PORTA_BASE,GPIO_PIN_0 | GPIO_PIN_1);
UARTStdioInit(0);
}
int main(void)
{
unsigned long ulADC0_Value[1];
unsigned longulTemp_ValueC;
unsigned long ulTemp_ValueF;
SysCtlClockSet(SYSCTL_SYSDIV_10 |SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);
InitConsole();
UARTprintf("ADC ->\n");
UARTprintf(" Type:Internal Temperature Sensor\n");
UARTprintf(" Samples: One\n");
UARTprintf(" UpdateRate: 250ms\n");
UARTprintf(" InputPin: Internal temperature sensor\n\n");
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0);
ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_TS | ADC_CTL_IE |ADC_CTL_END);
ADCSequenceEnable(ADC0_BASE, 3);
ADCIntClear(ADC0_BASE,3);
while(1)
{
ADCProcessorTrigger(ADC0_BASE, 3);
while(!ADCIntStatus(ADC0_BASE, 3, false))
{
}
ADCIntClear(ADC0_BASE, 3);
ADCSequenceDataGet(ADC0_BASE, 3, ulADC0_Value);
// ulTemp_ValueC = ((1475 * 1023) - (2250 * ulADC0_Value[0])) / 10230;
ulTemp_ValueC = ((1475 * 4095) - (2250 * ulADC0_Value[0])) /40950;
ulTemp_ValueF = ((ulTemp_ValueC * 9) + 160) / 5;
UARTprintf("Temperature = %3d*C or %3d*F\r",ulTemp_ValueC,ulTemp_ValueF);
SysCtlDelay(SysCtlClockGet() / 12);
}
}
SecureCRT的实用教程.doc
(474 KB, 下载次数: 5)
scrt712-x86.exe
(14.13 MB, 下载次数: 4)
操作图及程序.doc
(432.5 KB, 下载次数: 6)
|