找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 3730|回复: 2
收起左侧

MSP430F5529 LAB CODE的实验例程

[复制链接]
ID:368594 发表于 2018-7-10 12:03 | 显示全部楼层 |阅读模式
MSP430F5529 LAB CODE的实验例程
0.png

单片机源程序如下:
  1. //***************************************************************************//
  2. //                                                                           //
  3. //                          MSP-EXP430F5529 LAB CODE                         //
  4. //                                                                           //
  5. //                             LAB1main- Main file                           //
  6. //                                                                           //
  7. //***************************************************************************//

  8. #include <stdint.h>
  9. #include "msp430.h"
  10. #include "HAL_PMM.h"
  11. #include "HAL_UCS.h"
  12. #include "HAL_Board.h"
  13. #include "HAL_Buttons.h"
  14. #include "HAL_Dogs102x6.h"
  15. #include "HAL_Menu.h"
  16. #include "HAL_Wheel.h"
  17. #include "LPM.h"
  18. #include "PMM.h"
  19. #include "lab1.h"


  20. uint16_t timeoutCounter;

  21. // This image has been created by ImageDog using 'ti_bug.jpg'
  22. static const uint8_t tiBug[] =
  23. {
  24.     0x42,    // Image width in pixels
  25.     0x08,    // Image height in rows (1 row = 8 pixels)
  26.     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  27.     0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  28.     0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
  29.     0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  30.     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  31.     0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  32.     0xff, 0xff, 0xff, 0xff, 0x0f, 0x0f, 0x0f, 0x0f, 0x08, 0x00, 0x00, 0x0f, 0xcf, 0xcf, 0xcf, 0xcf,
  33.     0xcf, 0xc8, 0x00, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
  34.     0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  35.     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  36.     0xff, 0xff, 0xff, 0xff, 0xf8, 0xf0, 0xf0, 0xf0, 0xf0, 0xc0, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  37.     0xff, 0xfe, 0xc0, 0x00, 0x00, 0xf0, 0xf0, 0xf0, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  38.     0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x70, 0x7c, 0x7e, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
  39.     0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  40.     0xff, 0xff, 0xff, 0xff, 0xff, 0xcf, 0x0f, 0x0f, 0x0f, 0x00, 0x00, 0x01, 0x3f, 0xff, 0xff, 0xff,
  41.     0xff, 0xff, 0xf0, 0x00, 0x01, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  42.     0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0,
  43.     0xf0, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  44.     0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x80, 0x00, 0x0e, 0xfe, 0xfe, 0xfe,
  45.     0xfe, 0xfe, 0xfc, 0x80, 0x00, 0x0e, 0xfe, 0xfe, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  46.     0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  47.     0x00, 0x00, 0x00, 0x00, 0x80, 0xe0, 0xf0, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf0, 0xe0, 0xc0, 0x80,
  48.     0x80, 0x80, 0xc0, 0xc0, 0xf0, 0xf8, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x03, 0x03, 0x01, 0x01, 0x01,
  49.     0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0f, 0xff, 0xff, 0xff, 0xfe, 0xfe,
  50.     0xfc, 0xf8, 0xf0, 0xf0, 0xe0, 0xe0, 0xc0, 0xc0, 0xc0, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00,
  51.     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  52.     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xe0, 0xf8, 0xfe, 0xff, 0xff, 0xff,
  53.     0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xe0, 0xc0, 0x00,
  54.     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  55.     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  56.     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
  57.     0xc0, 0xf0, 0xf0, 0xf8, 0xfc, 0xfe, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x02, 0x00,
  58.     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  59. };



  60. void main(void)
  61. {
  62.     uint8_t contrast = *((unsigned char *)contrastSetpointAddress);            //读取FLASH中对比度值
  63.     uint8_t brightness = *((unsigned char *)brightnessSetpointAddress);        //读取FLASH中背光值

  64.     // Initialize accelerometer offset from flash
  65.    // Cma3000_setAccel_offset(*((unsigned char *)accelXcalibrationAddress),    //初始化加速度偏移量
  66.      //                       *((unsigned char *)accelYcalibrationAddress),
  67.        //                     *((unsigned char *)accelZcalibrationAddress));

  68.     // Stop WDT
  69.     WDTCTL = WDTPW + WDTHOLD;                     //关闭看门狗

  70.     // Basic GPIO initialization
  71.     Board_init();                                 //初始化GPIO

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

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

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

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

  80.     // Globally enable interrupts
  81.     __enable_interrupt();                        //使能全局中断

  82.     // Setup real time clock
  83.     SetupRTC();                                  //设置实时时钟

  84.     // Set up LCD
  85.     Dogs102x6_init();                            //初始化LCD
  86.     Dogs102x6_backlightInit();                   //背光初始化

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

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

  95.     Dogs102x6_setBacklight(brightness);          //设置初始背光值
  96.     Dogs102x6_setContrast(contrast);             //设置初始对比度值
  97.     Dogs102x6_clearScreen();                     //清屏

  98.     // Set up wheel
  99.     Wheel_init();                                //初始化齿轮电位计
  100.     Buttons_init(BUTTON_ALL);                    //初始化按键
  101.     Buttons_interruptEnable(BUTTON_ALL);         //使能所有按键中断
  102.     buttonsPressed = 0;                          //键值清零

  103.     // Display TI logo
  104.     Dogs102x6_imageDraw(tiBug, 0, 16);           //显示TI图案

  105.     // Wait for button press
  106.     while (!buttonsPressed)                     //等待按键被按下,或者超时退出等待
  107.     {
  108.         for (timeoutCounter = 0; timeoutCounter < 0xFFFF; timeoutCounter++)
  109.         {
  110.             if (buttonsPressed)
  111.                 break;
  112.             __delay_cycles(1000);
  113.         }

  114.         //Timeout break
  115.         break;                                   //超时退出
  116.     }
  117.     Dogs102x6_clearScreen();
  118.     buttonsPressed = 0;
  119.     //显示文字说明:
  120.     Dogs102x6_stringDraw(3, 0, "   Welcome to    ", DOGS102x6_DRAW_NORMAL);
  121.     Dogs102x6_stringDraw(4, 0, " MSP-EXP430F5529 ", DOGS102x6_DRAW_NORMAL);
  122.     Dogs102x6_stringDraw(6, 0, "Wait for a moment", DOGS102x6_DRAW_INVERT);
  123.     Dogs102x6_stringDraw(7, 0, "or press S1 | S2 ", DOGS102x6_DRAW_INVERT);

  124.     // Wait for button press
  125.     while (!buttonsPressed)                    //等待按键被按下,或者超时退出等待
  126.     {
  127.         for (timeoutCounter = 0; timeoutCounter < 0xFFFF; timeoutCounter++)
  128.         {
  129.             if (buttonsPressed)
  130.                 break;
  131.             __delay_cycles(2000);
  132.         }

  133.         //Timeout break
  134.         break;
  135.     }

  136.     // 主循环
  137.     while (1)
  138.     {
  139.             lab1();                               //试验一程序
  140.     }
  141. }
复制代码

所有资料51hei提供下载:
LAB1.zip (2.69 MB, 下载次数: 39)
回复

使用道具 举报

ID:494575 发表于 2019-3-25 12:50 | 显示全部楼层
为什么rts430.lib下载下来之后变成了一个压缩包
回复

使用道具 举报

ID:372912 发表于 2019-7-11 20:41 | 显示全部楼层
库文件里什么东西也没有啊
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表