新人研究5529遇到的编译问题

[复制链接]
10054|5
 楼主| mensaoliang 发表于 2013-8-2 14:40 | 显示全部楼层 |阅读模式
刚开始用,打算把开发板例程的LAB2和ADC12例程的单次采样比较相结合,但是遇到错误,对于解决这个问题没什么想法,来求教各位
先想问几个问题
1。新建工程添加头文件时一定要通过“选择“properties”,在出现的属性对话框中选择“Build”“MSP430 Complier”“include options””这样的步骤么?
2。新手通过更改现成的可编译成功的例程学习这样有帮助么?还是应该自己练习?
3。我在网上找到的大部分代码都只是部分核心代码,但是只要想加入自带led显示就会出现问题,请问这样有什么好的解决办法么?
----------------------------------------------------------------------------------------------------------------------------------------------------------------
错误如下
Description    Resource    Path    Location    Type
#10010 errors encountered during linking; "LAB2.out" not built    LAB2             C/C++ Problem
#10056 symbol "ADC12_ISR" redefined: first defined in "./lab2.obj";    LAB2             C/C++ Problem
<a href="file:/D:/Program%20Files/ti/ccsv5/tools/compiler/dmed/HTML/10099.html">#10099-D</a>  program will not fit into    lnk_msp430f5529.cmd    /LAB2    line 180    C/C++ Problem

ADC12部分代码
  1. //******************************************************************************
  2. //   MSP430F552x Demo - ADC12, Sample A0, Set P1.0 if A0 > 0.5*AVcc
  3. //
  4. //   Description: A single sample is made on A0 with reference to AVcc.
  5. //   Software sets ADC12SC to start sample and conversion - ADC12SC
  6. //   automatically cleared at EOC. ADC12 internal oscillator times sample (16x)
  7. //   and conversion. In Mainloop MSP430 waits in LPM0 to save power until ADC12
  8. //   conversion complete, ADC12_ISR will force exit from LPM0 in Mainloop on
  9. //   reti. If A0 > 0.5*AVcc, P1.0 set, else reset.
  10. //
  11. //                MSP430F552x
  12. //             -----------------
  13. //         /|\|                 |
  14. //          | |                 |
  15. //          --|RST              |
  16. //            |                 |
  17. //     Vin -->|P6.0/CB0/A0  P1.0|--> LED
  18. //
  19. //   Bhargavi Nisarga
  20. //   Texas Instruments Inc.
  21. //   April 2009
  22. //   Built with CCSv4 and IAR Embedded Workbench Version: 4.21
  23. //******************************************************************************

  24. #include <msp430f5529.h>

  25. void main(void)
  26. {
  27.   WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
  28.   ADC12CTL0 = ADC12SHT02 + ADC12ON;         // Sampling time, ADC12 on
  29.   ADC12CTL1 = ADC12SHP;                     // Use sampling timer
  30.   ADC12IE = 0x01;                           // Enable interrupt
  31.   ADC12CTL0 |= ADC12ENC;
  32.   P6SEL |= 0x01;                            // P6.0 ADC option select
  33.   P1DIR |= 0x01;                            // P1.0 output

  34.   while (1)
  35.   {
  36.     ADC12CTL0 |= ADC12SC;                   // Start sampling/conversion
  37.    
  38.     __bis_SR_register(LPM0_bits + GIE);     // LPM0, ADC12_ISR will force exit
  39.     __no_operation();                       // For debugger
  40.   }
  41. }

  42. #pragma vector = ADC12_VECTOR
  43. __interrupt void ADC12_ISR(void)
  44. {
  45.   switch(__even_in_range(ADC12IV,34))
  46.   {
  47.   case  0: break;                           // Vector  0:  No interrupt
  48.   case  2: break;                           // Vector  2:  ADC overflow
  49.   case  4: break;                           // Vector  4:  ADC timing overflow
  50.   case  6:                                  // Vector  6:  ADC12IFG0
  51.     if (ADC12MEM0 >= 0x7ff)                 // ADC12MEM = A0 > 0.5AVcc?
  52.       P1OUT |= BIT0;                        // P1.0 = 1
  53.     else
  54.       P1OUT &= ~BIT0;                       // P1.0 = 0

  55.     __bic_SR_register_on_exit(LPM0_bits);   // Exit active CPU
  56.   case  8: break;                           // Vector  8:  ADC12IFG1
  57.   case 10: break;                           // Vector 10:  ADC12IFG2
  58.   case 12: break;                           // Vector 12:  ADC12IFG3
  59.   case 14: break;                           // Vector 14:  ADC12IFG4
  60.   case 16: break;                           // Vector 16:  ADC12IFG5
  61.   case 18: break;                           // Vector 18:  ADC12IFG6
  62.   case 20: break;                           // Vector 20:  ADC12IFG7
  63.   case 22: break;                           // Vector 22:  ADC12IFG8
  64.   case 24: break;                           // Vector 24:  ADC12IFG9
  65.   case 26: break;                           // Vector 26:  ADC12IFG10
  66.   case 28: break;                           // Vector 28:  ADC12IFG11
  67.   case 30: break;                           // Vector 30:  ADC12IFG12
  68.   case 32: break;                           // Vector 32:  ADC12IFG13
  69.   case 34: break;                           // Vector 34:  ADC12IFG14
  70.   default: break;
  71.   }
  72. }

自改程序部分:
主程序
  1. #include <stdint.h>
  2. #include "msp430.h"
  3. #include "HAL_PMM.h"
  4. #include "HAL_UCS.h"
  5. #include "HAL_Board.h"
  6. #include "HAL_Buttons.h"
  7. #include "HAL_Cma3000.h"
  8. #include "HAL_Dogs102x6.h"
  9. #include "HAL_Menu.h"
  10. #include "HAL_Wheel.h"
  11. #include "LPM.h"
  12. #include "PMM.h"
  13. #include "lab2.h"
  14. uint16_t timeoutCounter;


  15. void main(void)
  16. {
  17.     uint8_t contrast = *((unsigned char *)contrastSetpointAddress);            //读取FLASH中对比度值
  18.     uint8_t brightness = *((unsigned char *)brightnessSetpointAddress);        //读取FLASH中背光值

  19.     // Initialize accelerometer offset from flash
  20.     Cma3000_setAccel_offset(*((unsigned char *)accelXcalibrationAddress),     //初始化加速度偏移量
  21.                             *((unsigned char *)accelYcalibrationAddress),
  22.                             *((unsigned char *)accelZcalibrationAddress));

  23.     // Stop WDT
  24.     WDTCTL = WDTPW + WDTHOLD;                     //关闭看门狗

  25.     // Basic GPIO initialization
  26.     Board_init();                                 //初始化GPIO

  27.     // Set Vcore to accomodate for max. allowed system speed
  28.     SetVCore(3);                                  //设VCore为最大

  29.     // Use 32.768kHz XTAL as reference
  30.     LFXT_Start(XT1DRIVE_0);                       //利用LFXT1(32.768kHZ)作为时钟参考

  31.     // Set system clock to max (25MHz)
  32.     Init_FLL_Settle(25000, 762);                 //利用FLL(锁频环)将系统时钟设为最大25MHZ

  33.     SFRIFG1 = 0;                                 //清中断标志
  34.     SFRIE1 |= OFIE;                              //使能晶振失效中断

  35.     // Globally enable interrupts
  36.     __enable_interrupt();                        //使能全局中断

  37.     // Setup real time clock
  38.     //SetupRTC();                                  //设置实时时钟

  39.     // Set up LCD
  40.     Dogs102x6_init();                            //初始化LCD
  41.     Dogs102x6_backlightInit();                   //背光初始化

  42.     // Contrast not programed in Flash Yet
  43.     if (contrast == 0xFF)                        //若当前FLASH中无对比度值,则将对比度值设为11(默认)
  44.         // Set Default Contrast
  45.         contrast = 11;

  46.     // Brightness not programed in Flash Yet
  47.     if (brightness == 0xFF)                      //若当前FLASH中无背光值,则将背光值设为11(默认)
  48.         // Set Default Brightness
  49.         brightness = 11;

  50.     Dogs102x6_setBacklight(brightness);          //设置初始背光值
  51.     Dogs102x6_setContrast(contrast);             //设置初始对比度值
  52.     Dogs102x6_clearScreen();                     //清屏

  53.     // Set up wheel
  54.     Wheel_init();                                //初始化齿轮电位计
  55.     Buttons_init(BUTTON_ALL);                    //初始化按键
  56.     Buttons_interruptEnable(BUTTON_ALL);         //使能所有按键中断
  57.     buttonsPressed = 0;                          //键值清零

  58.     // Display TI **
  59.   // Wait for button press

  60. //    buttonsPressed = 0;
  61.     //显示文字说明:
  62.     Dogs102x6_stringDraw(3, 0, "   Welcome to    ", DOGS102x6_DRAW_NORMAL);
  63.     Dogs102x6_stringDraw(4, 0, " MSP-EXP430F5529 ", DOGS102x6_DRAW_NORMAL);
  64.     Dogs102x6_stringDraw(6, 0, "Wait for a moment", DOGS102x6_DRAW_INVERT);
  65.     Dogs102x6_stringDraw(7, 0, "or press S1 | S2 ", DOGS102x6_DRAW_INVERT);

  66.     // Wait for button press
  67.     while (!buttonsPressed)                    //等待按键被按下,或者超时退出等待
  68.     {
  69.         for (timeoutCounter = 0; timeoutCounter < 0xFFFF; timeoutCounter++)
  70.         {
  71.             if (buttonsPressed)
  72.                 break;
  73.             __delay_cycles(2000);
  74.         }

  75.         //Timeout break
  76.         break;
  77.     }

  78.     // 主循环
  79.     while (1)
  80.     {
  81.             lab2();                               //试验二程序
  82.     }
  83. }

lab2
  1. #include <stdint.h>
  2. #include "msp430.h"
  3. #include "HAL_PMM.h"
  4. #include "HAL_UCS.h"
  5. #include "HAL_Board.h"
  6. #include "HAL_Buttons.h"
  7. #include "HAL_Dogs102x6.h"
  8. #include "HAL_Menu.h"
  9. #include "HAL_Wheel.h"
  10. #include "Clock.h"
  11. #include "LPM.h"
  12. #include "Random.h"
  13. #include "PMM.h"
  14. #include "Demo_Cube.h"
  15. #include "CTS_Layer.h"
  16. #include "stdlib.h"
  17. #include "lab2.h"

  18. static const char *const capMenuText[] = {
  19.     "==LAB2:Cap App===",
  20.     "1. CapLED ",
  21.     "2. CapDemo ",
  22.     "3. Simon",
  23. };
  24. char *itoa(int, char *, int);

  25. // Forward Declared Function
  26. void CapLED(void);
  27. void CapDemo(void);
  28. void simon(void);

  29. void lab2(void)
  30. {
  31.            uint8_t selection = 0;

  32.             buttonsPressed = 0;

  33.             Dogs102x6_clearScreen();

  34.             Dogs102x6_stringDraw(7, 0, "*S1=Enter S2=Esc*", DOGS102x6_DRAW_NORMAL);
  35.             selection = Menu_active((char **)capMenuText, 1);
  36.             if (buttonsPressed & BUTTON_S2);
  37.             else
  38.                switch (selection)
  39.                 {
  40.                 case 1: CapLED(); break;           //触摸滑块演示实验程序
  41.                           //触摸按键柱形图演示实验程序
  42.                            //Simon游戏实验程序
  43.                     default: break;
  44.                 }
  45. }

  46. void CapLED(void)
  47. {
  48.     Board_ledOff(LED_ALL);                           //关闭所有LED
  49.     Dogs102x6_clearScreen();
  50.     buttonsPressed = 0;

  51.     Dogs102x6_stringDraw(1, 0, " Slide Finger on ", DOGS102x6_DRAW_NORMAL);
  52.     Dogs102x6_stringDraw(2, 0, "   Touch Pads    ", DOGS102x6_DRAW_NORMAL);

  53.     while (!(buttonsPressed & BUTTON_S2))           //S2按键按下退出程序
  54.     {
  55.             WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
  56.               ADC12CTL0 = ADC12SHT02 + ADC12ON;         // Sampling time, ADC12 on
  57.               ADC12CTL1 = ADC12SHP;                     // Use sampling timer
  58.               ADC12IE = 0x01;                           // Enable interrupt
  59.               ADC12CTL0 |= ADC12ENC;
  60.               P6SEL |= 0x01;                            // P6.0 ADC option select
  61.               P1DIR |= 0x01;                            // P1.0 output

  62.               while (1)
  63.               {
  64.                 ADC12CTL0 |= ADC12SC;                   // Start sampling/conversion

  65.                 __bis_SR_register(LPM0_bits + GIE);     // LPM0, ADC12_ISR will force exit
  66.                 __no_operation();                       // For debugger
  67.               }
  68.     }

  69.     Board_ledOff(LED_ALL);
  70.     Dogs102x6_clearScreen();
  71.     buttonsPressed = 0;
  72. }
  73. #pragma vector = ADC12_VECTOR
  74. __interrupt void ADC12_ISR(void)
  75. {
  76.   switch(__even_in_range(ADC12IV,34))
  77.   {
  78.   case  0: break;                           // Vector  0:  No interrupt
  79.   case  2: break;                           // Vector  2:  ADC overflow
  80.   case  4: break;                           // Vector  4:  ADC timing overflow
  81.   case  6:                                  // Vector  6:  ADC12IFG0
  82.     if (ADC12MEM0 >= 0x7ff)                 // ADC12MEM = A0 > 0.5AVcc?
  83.       P1OUT |= BIT0;                        // P1.0 = 1
  84.     else
  85.       P1OUT &= ~BIT0;                       // P1.0 = 0

  86.     __bic_SR_register_on_exit(LPM0_bits);   // Exit active CPU
  87.   case  8: break;                           // Vector  8:  ADC12IFG1
  88.   case 10: break;                           // Vector 10:  ADC12IFG2
  89.   case 12: break;                           // Vector 12:  ADC12IFG3
  90.   case 14: break;                           // Vector 14:  ADC12IFG4
  91.   case 16: break;                           // Vector 16:  ADC12IFG5
  92.   case 18: break;                           // Vector 18:  ADC12IFG6
  93.   case 20: break;                           // Vector 20:  ADC12IFG7
  94.   case 22: break;                           // Vector 22:  ADC12IFG8
  95.   case 24: break;                           // Vector 24:  ADC12IFG9
  96.   case 26: break;                           // Vector 26:  ADC12IFG10
  97.   case 28: break;                           // Vector 28:  ADC12IFG11
  98.   case 30: break;                           // Vector 30:  ADC12IFG12
  99.   case 32: break;                           // Vector 32:  ADC12IFG13
  100.   case 34: break;                           // Vector 34:  ADC12IFG14
  101.   default: break;
  102.   }
  103. }




谢谢各位了先

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
airwill 发表于 2013-8-2 15:27 | 显示全部楼层
自己建工程, 是肯定要学会的.
用例程来学习, 肯定会比较快些入门
1988020566 发表于 2013-8-2 23:14 | 显示全部楼层
重新编译试试的。
1988020566 发表于 2013-8-2 23:14 | 显示全部楼层
应该是缺少包含路径的。
dirtwillfly 发表于 2013-8-3 12:02 | 显示全部楼层
https://bbs.21ic.com/icview-584664-1-1.html
这里有学习5529的一些教程,你可以学习下。建立工程和学习写自己的代码是最基本的了……
dirtwillfly 发表于 2013-12-24 20:46 | 显示全部楼层
楼主的问题解决了吗?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

1

主题

1

帖子

0

粉丝
快速回复 在线客服 返回列表 返回顶部