能不能告诉我原因,照片在附件处
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.
我是这么使用这个例程的,我把关于ADC定义的那一部分代码,复制后,把gamepad里面的adc代码替换掉,我想用MDK重新搭建,但是不会,有没有完整的详细的教程,谢谢
应该是官方的算法不对,你看看这个例程,是没问题的。
// sensor. // // Copyright (c) 2010-2017 Texas Instruments Incorporated. All rights reserved. // Software License Agreement // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // // Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the // distribution. // // Neither the name of Texas Instruments Incorporated nor the names of // its contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // This is part of revision 2.1.4.178 of the Tiva Firmware Development Package. // //***************************************************************************** #include <stdbool.h> #include <stdint.h> #include "inc/hw_memmap.h" #include "driverlib/adc.h" #include "driverlib/gpio.h" #include "driverlib/pin_map.h" #include "driverlib/sysctl.h" #include "driverlib/uart.h" #include "utils/uartstdio.h" //***************************************************************************** // //! \addtogroup adc_examples_list //! <h1>ADC Temperature Sensor (temperature_sensor)</h1> //! //! This example shows how to setup ADC0 to read the internal temperature //! sensor. //! //! NOTE: The internal temperature sensor is not calibrated. This example //! just takes the raw temperature sensor sample and converts it using the //! equation found in the LM3S9B96 datasheet. //! //! This example uses the following peripherals and I/O signals. You must //! review these and change as needed for your own board: //! - ADC0 peripheral //! //! The following UART signals are configured only for displaying console //! messages for this example. These are not required for operation of the //! ADC. //! - UART0 peripheral //! - GPIO Port A peripheral (for UART0 pins) //! - UART0RX - PA0 //! - UART0TX - PA1 //! //! This example uses the following interrupt handlers. To use this example //! in your own application you must add these interrupt handlers to your //! vector table. //! - None. // //***************************************************************************** //***************************************************************************** // // This function sets up UART0 to be used for a console to display information // as the example is running. // //***************************************************************************** void InitConsole(void) { // // Enable GPIO port A which is used for UART0 pins. // TODO: change this to whichever GPIO port you are using. // SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); // // Configure the pin muxing for UART0 functions on port A0 and A1. // This step is not necessary if your part does not support pin muxing. // TODO: change this to select the port/pin you are using. // GPIOPinConfigure(GPIO_PA0_U0RX); GPIOPinConfigure(GPIO_PA1_U0TX); // // Enable UART0 so that we can configure the clock. // SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); // // Use the internal 16MHz oscillator as the UART clock source. // UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC); // // Select the alternate (UART) function for these pins. // TODO: change this to select the port/pin you are using. // GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); // // Initialize the UART for console I/O. // UARTStdioConfig(0, 115200, 16000000); } int main(void) { uint32_t ui32ADC0Value[4]; volatile uint32_t ui32TempAvg; volatile uint32_t ui32TempValueC; volatile uint32_t ui32TempValueF; SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ); InitConsole(); // // Display the setup on the console. // UARTprintf("ADC ->\n"); UARTprintf(" Type: Internal Temperature Sensor\n"); UARTprintf(" Samples: One\n"); UARTprintf(" Update Rate: 250ms\n"); UARTprintf(" Input Pin: Internal temperature sensor\n\n"); //5分频,使用PLL,外部晶振16M,system时钟源选择 main osc。系统时钟40MHZ SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); //使能ADC0 ADCSequenceConfigure(ADC0_BASE, 1, ADC_TRIGGER_PROCESSOR, 0); //We want to use ADC0, sample sequencer 1, //we want the processor to trigger the sequence and we want to use the highest priority ADCSequenceStepConfigure(ADC0_BASE, 1, 0, ADC_CTL_TS); ADCSequenceStepConfigure(ADC0_BASE, 1, 1, ADC_CTL_TS); ADCSequenceStepConfigure(ADC0_BASE, 1, 2, ADC_CTL_TS); //Configure steps 0 - 2 on sequencer 1 to sample the temperature sensor (ADC_CTL_TS). ADCSequenceStepConfigure(ADC0_BASE,1,3,ADC_CTL_TS|ADC_CTL_IE|ADC_CTL_END); //Sample the temperature sensor (ADC_CTL_TS) and configure the interrupt flag (ADC_CTL_IE) //Tell the ADC logic that this is the last conversion on sequencer1 (ADC_CTL_END). ADCSequenceEnable(ADC0_BASE, 1); //enable ADC sequencer 1 while(1) { ADCIntClear(ADC0_BASE, 1); ADCProcessorTrigger(ADC0_BASE, 1); //trigger the ADC conversion with software while(!ADCIntStatus(ADC0_BASE, 1, false)) { } //wait for the conversion to complete ADCSequenceDataGet(ADC0_BASE, 1, ui32ADC0Value); ui32TempAvg = (ui32ADC0Value[0] + ui32ADC0Value[1] + ui32ADC0Value[2] + ui32ADC0Value[3] + 2)/4; //Since 2/4 = 1/2 = 0.5, 1.5 will be rounded to 2.0 with //the addition of 0.5. In the case of 1.0, when 0.5 is added to yield 1.5, this will be rounded //back down to 1.0 due to the rules of integer math.即四舍五入 ui32TempValueC = (1475 - ((2475 * ui32TempAvg)) / 4096)/10; //TEMP = 147.5 – ((75 * (VREFP – VREFN) * ADCVALUE) / 4096) //VREFP – VREFN=3.3V ui32TempValueF = ((ui32TempValueC * 9) + 160) / 5; UARTprintf("Temperature = %d*C or %d*F\r\n", ui32TempValueC, ui32TempValueF); //F = ( C * 9)/5 +32 } }
好厉害,那处理四路数据,的算法是不是也可以这样写,例程里面的一路数据输出的AIN代表什么意思
我在南京,测得温度是16摄氏度,现在就在尝试外设四路数据的结算采集,但是还是不清楚如何将采集的数据解算
ADC ->
Type: Internal Temperature Sensor
Samples: One
Update Rate: 250ms
Input Pin: AIN0/PE3
Temperature = 6*C or 42*F or 2331
Temperature = 11*C or 51*F or 2253
Temperature = 10*C or 50*F or 2277
Temperature = 11*C or 51*F or 2251
Temperature = 36*C or 96*F or 1842
Temperature = 14*C or 57*F or 2206
Temperature = 17*C or 62*F or 2155
Temperature = 24*C or 75*F or 2043
Temperature = 23*C or 73*F or 2049
Temperature = 23*C or 73*F or 2055
Temperature = 23*C or 73*F or 2053
Temperature = 23*C or 73*F or 2048
Temperature = 24*C or 75*F or 2041
Temperature = 23*C or 73*F or 2051
Temperature = 24*C or 75*F or 2041
Temperature = 24*C or 75*F or 2040
Temperature = 23*C or 73*F or 2048
Temperature = 24*C or 75*F or 2037
Temperature = 23*C or 73*F or 2059
Temperature = 23*C or 73*F or 2054
Temperature = 23*C or 73*F or 2055
Temperature = 23*C or 73*F or 2049
Temperature = 23*C or 73*F or 2049
Temperature = 23*C 272T27* 2** 2*72T272 2** 2** T272T272 2** 2**2T272T2** 2** 2*72T272 2** 2** T272T272 2** 2**2T742T6* T9* T** T**2T142T5* T6* 7** 7** 6** 1** 6** 6** 8** 842 742 742T142T742T642T742T6* T6* T142T7* T8* T*52T172T2** 2** 2*72T272 2** 2** T272T272 2** 2** T272T27* 2** 2*72T272 2** 2** T272T272 2** 2** T272T27* 2** 2*72T272 2** 1** 7** 6** 1** 7** 1** 7** 8** 8** 7** 7** 7** 542 642 542T742T742T542T9* T** T** 8** 8** 5** 1** 1** 1** T*52T252 2** 2** T272T272 2** 2**2T272T2** 2** 2*72T272 2** 2** T272T272 2** 2** T272T27* 2** 2*72T272 2** 2** T272T272 1** 8** 1** 6** 8** 7** 6** 5** 5** 542 642T842T642T742T64 T5* T** 5** 6** 7** 8** 7** 6** 842 1** 952 942 842 742 2** 2** T272T272 2** 2**2T272T2** 2** 2*72T272 2** 2** T272T272 2** 2** T272T27* 2** 2*72T272 2** 2** T272T272 2** 1** T8* T** 9** 7** 8** 6** 6** 6** 6** 8** 6** 842 442T642T542T642T6* T142T7* T6* T** 7** 8** 8** 1** 8** 1** 9** T152T272 2** 2** T272T27* 2** 2**2T272 2** 2** T*72T272 2** 2** T272T272 2** 2**2T272T2** 2** 2*72T272 2** 2** T272T152 1** 9** 642 652 1*2 542 742 542T642T842T842T6* T** T** 7** 6** 6** 1** 7** 8** 7** 7** 942 74* 1** 7** 1** 1** T162T272 2** 2**2T272 2** 2** 2*72T272 2** 2** T272T272 2** 2** T272T27* 2** 2**2T272 2** 2** T272T272 2** 2** T272T16* 842 742 1** 742 64* 542 542T742T542T942T442T7* T6* T** 7** 8** 6** 5** 1** 6** 7** 742 742 842 142 1** 1** 1** T172T27* 2** 2**2T272 2** 2** T272T272 2** 2** T272T272 2** 2** T272T2** 2** 2*72T272 2** 2** T272T272 2** 2** T272T242 1** 942 842 842 542 142 742 642T642T542T642T8* T** T** 8** 6** 6** 6** 8** 742 842 742T742T942T842T752T842T162 1** 2** T272T272 2** 2** T272T272 2** 2**2T272T2** 2** 2*72T272 2** 2** T272T272 2** 2** T272T27* 2** 2*72T272 2** 2** 8** 9** 6** 5** 9** 9** 6** 7** 742 842T642T642T542T6* T6* T6* 7** 9** 8** 7** 7** 8** 642 1** 942 9** 9** 1** 1*72T272 2** 2** T272T272 2** 2** T272T27* 2** 2**2T272 2** 2** 2*72T272 2** 2** T272T272 2** 2** T272T2** 2** 2*62T142T942T842T142T642T142T642T642T7* T** T** 8** 6** 6** 5** 8** 8** 642 742 842T642T742T742T7*2T142T152T152 1** 2** 2*72T272 2** 2** T272T272 2** 2** T272T27* 2** 2**2T272 2** 2** T272T272 2** 2** T272T272 2** 2**2T272 2** 2** T*52T842T742T642T152T742T742T542T6* T6* T8* 8** 1** 6** 6** 6** 8** 6** 7*2 642 752 742T842T742T742T7* T152T152T142 2** 2** T272T27* 2** 2*72T272 2** 2** T272T272 2** 2** T272T272 2** 2** T272T2** 2** 2*72T272 2** 2** T272T272 2** 1** T8*2T6* T** T7* 7** 6** 7** 1** 5** 6** 6** 8** 6** 6** 742 742T642T742T142T642T642T642T742T842T142 1** 9** 1** 1** T272T27* 2** 2*72T272 2** 2** T272T272 2** 2** T272T272 2** 2**2T272T2** 2** 2*72T272 2** 2** T272T272 2** 2** T172T742T942T842T74 T7* T4* T** 6** 1** 6** 7** 9** 4** 7** 642 742 142 842T742T142T842T642T742T142T852T952T952T15* 1** 2*72T272 2** 2** T272T272 2** 2** T272T272 2** 2** T272T27* 2** 2*72T272 2** 2** T272T272 2** 2** T272T272 2** 1** T** T** T7* 7** 7** 8** 7** 6** 6** 842 642 642T642T842T642T7* T** T** 6** 7** 8** 8** 6** 1** 8** 8** 7** 1** T172T27* 2** 2**2T272 2** 2** 2*72T272 2** 2** T272T272 2** 2**2T272T2** 2** 2*72T272 2** 2** T272T272 2** 2** T272T242 942 852 64* 74* 642 642T852T642T742T642T8* T6* T** T** 7** 9** 5** 6** 7** 7** 742 642 842T152 842 142 1** 1** T272T27* 2** 2**2T272 2** 2** T*72T272 2** 2** T272T272 2** 2** T272T27* 2** 2**2T272 2** 2** T272T272 2** 2** T262T742T642T942T142T142T842T842T832T6* T** T** 8** 6** 6** 7** 8** 542 842 842T742T742T842T8* T7* T8* T** T9* T152T27* 2** 2*72T272 2** 2** T272T272 2** 2** T272T272 2** 2**2T272T27* 2** 2*72T272 2** 2** T272T272 2** 2** T272T27* 2** 1** T** T** T8* T** 6** 6** 5** 6** 7** 8** 742 542 642T752T742T542T7* T8* T** T** 7** 6** 9** 7** 8** 1** 1** T252T272 2** 2** T272T272 2** 2**2T272T2** 2** 2*72T272 2** 2** T272T272 2** 2** T272T272 2** 2**2T272T2** 2** 2*72T152 642 742T742T752T742T542T742T742T8* T** T** 8** 6** 6** 6** 7** 642 642 942T842T642T742T8* T7* T** T152T152 1** 2** T272T272 2** 2** T272T272 2** 2**2T272T2** 2** 2*72T272 2** 2** T272T272 2** 2** T272T27* 2** 2**2T272T2** 2** 1*52T742T742T742T942T142T542T842T832T6* T** 9** 7** 5** 6** 9** 5** 642 742T742T642T642T74 T6* T** T** T** T9* T852T152 2** 2** T272T272 2** 2** T272T272 2** 2**2T272T2** 2** 2*72T272 2** 2** T272T272 2** 2** T272T272 2** 2**2T272T1** 8** 7** 6** 7** 7** 6** 542 432T542T742T642T542T6* T** T** 7** 7** 8** 8** 6** 642 642 842T842T842T942T152 1** 1** T272T272 2** 2** T272T27* 2** 2**2T272T2** 2** 2*72T272 2** 2** T272T272 2** 2** T272T27* 2** 2**2T272 2** 2** T*62T852T842T742T6*2T742T8* T** T** T** 5** 5** 9** 7** 6** 742 742 642T742T842T742T842T7* T** T** T142T152T842T15* 1** 2**2T272 2** 2** T*72T272 2** 2** T272T272 2** 2** T272T27* 2** 2**2T272T2** 2** 2*72T272 2** 2** T272T272 2** 1** T** 7** 7** 1** 1** T** T** T** T** T6* 6** 7** 7** 5** 6** 542 1** 642 852 742 742T542T842T142 942 942 1** 1** 1*72T272 2** 2** T272T272 2** 2** T272T272 2** 2** T272T27* 2** 2*72T272 2** 2** T272T272 2** 2** T272T272 2** 2**2T742T9* T152T752T842T142T142T542T642T742T6* T7* T** 6** 8** 6** 6** 7** 642 742 642T842T942T742T8* T9*2T152T1** 2** T*72T272 2** 2** T272T272 2** 2** T272T27* 2** 2*72T272 2** 2** T272T272 2** 2** T272T272 2** 2**2T272T2** 2** 2*52T542T842T142T142T842T8*2T4* T6* 6** 7** 7** 7** 5** 642 642 642T642T842T842T6* T7* 7** 7** 7** 1** 8** T152T952T25* 2** 2**2T272 2** 2** T272T272 2** 2** T272T272 2** 2** T272T27* 2** 2**2T272 2** 2** T272T272 2** 2** T272T272 1** 9** 7** 6** 9** 8** 6** 8** 742 642 142 642 642T542T642T642T7* T** T** T** T** T** 7** 7** 8** 1** 6** 1**2T9*2T152 2** 2** T272T272 2** 2** T272T272 2** 2** T272T27* 2** 2**2T272 2** 2** T272T272 2** 2** T272T272 2** 2** T272T15* 642 642 842T542T842T832T742T642T5* T** T** 7** 6** 5** 5** 8** 7** 8** 742 642 742T642T742T642T142T942T142T15* 1** 2*72T272 2** 2** T272T272 2** 2** T272T272 2** 2** T272T27* 2** 2*72T272 2** 2** T272T272 2** 2** T272T272 2** 1**2T9* T** T8* 1** T6* T** T** 6** 7** 5** 7** 6** 6** 542 842 742T642T842T542T642T6* T** T** T152T142T152T152 1** 1** 2*72T272 2** 2**
这是我收到的数据,好奇怪,能不能把你的那个完整例程发给我呀,我不会新建工程,使用的时候是把game_pad后面的ADC部分换掉
HELP
谢谢
而且我把sequence换成3的时候,提取出来的数据就不一样了
CCS的工程直接复制过去是不能直接使用的。你还是对adc的原理不清楚,出现错误的数据就很正常了。你替换的是哪部分的代码呢?想要实现什么样的功能呢?
外接传感器,接收数据,并且结算,我用的是keil5,ccs装上去不管哪个版本,都会出现缺少编译器,请问我该如何去做
现在想自己利用keil5创建一个TM4C123GXL的工程,但是没有一个详细的教程,不知道该如何去创建,能否帮我一下,一点也不懂.自己尝试了一下。全是错误,不知道该添加哪些文件,不知道步骤,非常感谢
谢谢
关于MDK创建例程的步骤,可以去21ic翻翻,这个论坛应该也有的。我发表过这样一个帖子。
能不能帮忙解决一下数据出错的问题,可否把你创建的工程,发一份给我
万分感谢
http://bbs.21ic.com/icview-857279-1-1.html
这是创建CCS工程的步骤。MDK的帖子我记得发了,原来没发,或者没找到,你去找找别人的吧,或者看看清风的教程,他应该有的。
**** Clean-only build of configuration Debug for project TEMPERATURE ****
"c:\\ti\\ccsv6\\utils\\bin\\gmake" -k clean
gmake: *** No rule to make target `clean'.
**** Build Finished ****
**** Build of configuration Debug for project TEMPERATURE ****
"c:\\ti\\ccsv6\\utils\\bin\\gmake" -k all
'Building file: ../temperature_sensor two.c'
'Invoking: ARM Compiler'
"c:/ti/ccsv6/tools/compiler/arm_5.1.5/bin/armcl" -mv7M4 --code_state=16 --float_support=FPv4SPD16 --abi=eabi -me --include_path="c:/ti/ccsv6/tools/compiler/arm_5.1.5/include" --include_path="C:/ti/TivaWare_C_Series-2.1.4.178" -g --define=PART_TM4C123GH6PM --define=TARGET_IS_BLIZZARD_RB1 --display_error_number --diag_warning=225 --diag_wrap=off --preproc_with_compile --preproc_dependency="temperature_sensor two.pp" "../temperature_sensor two.c"
'Finished building: ../temperature_sensor two.c'
' '
'Building file: ../tm4c123gh6pm_startup_ccs.c'
'Invoking: ARM Compiler'
"c:/ti/ccsv6/tools/compiler/arm_5.1.5/bin/armcl" -mv7M4 --code_state=16 --float_support=FPv4SPD16 --abi=eabi -me --include_path="c:/ti/ccsv6/tools/compiler/arm_5.1.5/include" --include_path="C:/ti/TivaWare_C_Series-2.1.4.178" -g --define=PART_TM4C123GH6PM --define=TARGET_IS_BLIZZARD_RB1 --display_error_number --diag_warning=225 --diag_wrap=off --preproc_with_compile --preproc_dependency="tm4c123gh6pm_startup_ccs.pp" "../tm4c123gh6pm_startup_ccs.c"
'Finished building: ../tm4c123gh6pm_startup_ccs.c'
' '
'Building target: TEMPERATURE.out'
'Invoking: ARM Linker'
"c:/ti/ccsv6/tools/compiler/arm_5.1.5/bin/armcl" -mv7M4 --code_state=16 --float_support=FPv4SPD16 --abi=eabi -me -g --define=PART_TM4C123GH6PM --define=TARGET_IS_BLIZZARD_RB1 --display_error_number --diag_warning=225 --diag_wrap=off -z -m"TEMPERATURE.map" --heap_size=0 --stack_size=512 -i"c:/ti/ccsv6/tools/compiler/arm_5.1.5/lib" -i"c:/ti/ccsv6/tools/compiler/arm_5.1.5/include" --reread_libs --warn_sections --display_error_number --diag_wrap=off --xml_link_info="TEMPERATURE_linkInfo.xml" --rom_model -o "TEMPERATURE.out" "./tm4c123gh6pm_startup_ccs.obj" "./temperature_sensor two.obj" "C:/ti/TivaWare_C_Series-2.1.4.178/driverlib/ccs/Debug/driverlib.lib" "../tm4c123gh6pm.cmd" -l"libc.a"
<Linking>
undefined first referenced
symbol in file
--------- ----------------
UARTStdioConfig ./temperature_sensor two.obj
UARTprintf ./temperature_sensor two.obj
error #10234-D: unresolved symbols remain
error #10010: errors encountered during linking; "TEMPERATURE.out" not built
>> Compilation failure
gmake: *** [TEMPERATURE.out] Error 1
gmake: Target `all' not remade because of errors.
**** Build Finished ****
这是我用ccs6.0,依照你发的连接一步一步做的,里面的c文件就是你改编的内部温度传感器的,出现了上面的错误,我选用的芯片是TM4C123GH6PM.提示4个错误,谢谢指点