打印
[其他]

【TI 测评】从两段点亮msp432的LED的程序说起

[复制链接]
745|11
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
dirtwillfly|  楼主 | 2019-9-25 20:46 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
原贴发在:https://e2echina.ti.com/question_answer/microcontrollers/msp430/f/55/t/180250
第一个程序:
/*******************************************************************************
* MSP432 GPIO - Toggle Output High/Low
*
* Description: In this very simple example, the LED on P1.0 is configured as
* an output using DriverLib's GPIO APIs. An infinite loop is then started
* which will continuously toggle the GPIO and effectively blink the LED.
*
*                MSP432P401
*             ------------------
*         /|\|                  |
*          | |                  |
*          --|RST         P1.0  |---> P1.0 LED
*            |                  |
*            |                  |
*            |                  |
*            |                  |
*
* Author: Timothy Logan
******************************************************************************/
/* DriverLib Includes */
#include "driverlib.h"

/* Standard Includes */
#include <stdint.h>

#include <stdbool.h>

int main(void)
{
    volatile uint32_t ii;

    /* Halting the Watchdog */
    MAP_WDT_A_holdTimer();

    /* Configuring P1.0 as output */
    MAP_GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN0);

    while (1)
    {
        /* Delay Loop */
        for(ii=0;ii<5000;ii++)
        {
        }

        MAP_GPIO_toggleOutputOnPin(GPIO_PORT_P1, GPIO_PIN0);
    }
}


使用特权

评论回复

相关帖子

沙发
dirtwillfly|  楼主 | 2019-9-25 20:47 | 只看该作者
第二个程序:
//***************************************************************************************
//  Blink the LED Demo - Software Toggle P1.0
//
//  Description; Toggle P1.0 inside of a software loop.
//  ACLK = n/a, MCLK = SMCLK = default DCO
//
//                MSP432P4xx
//             -----------------
//         /|\|              XIN|-
//          | |                 |
//          --|RST          XOUT|-
//            |                 |
//            |             P1.0|-->LED
//
//  E. Chen
//  Texas Instruments, Inc
//  March 2015
//  Built with Code Composer Studio v6
//***************************************************************************************

#include <ti/devices/msp432p4xx/driverlib/driverlib.h>

int main(void)
{
    volatile uint32_t i;

    // Stop watchdog timer
    WDT_A_hold(WDT_A_BASE);

    // Set P1.0 to output direction
    GPIO_setAsOutputPin(
        GPIO_PORT_P1,
        GPIO_PIN0
        );

    while(1)
    {
        // Toggle P1.0 output
        GPIO_toggleOutputOnPin(
            GPIO_PORT_P1,
            GPIO_PIN0
            );

        // Delay
        for(i=100000; i>0; i--);
    }
}


使用特权

评论回复
板凳
dirtwillfly|  楼主 | 2019-9-25 20:47 | 只看该作者
看起来,两段程序似乎并没有什么不同。除了引用的头文件不一样,还有就是第二段程序使用的函数名称少了“MAP_”。(本帖不讨论固化在rom里的库函数问题)
是的。这两段程序,点亮led的逻辑完全一致,他们的最大不同就是使用平台(或者说库)不同。第一段程序是基于msp432的driverlib,第二段程序是基于SimpleLink MSP432P4 SDK。这一点,可以从工程包含的头文件进行简单了解。
第一段程序包含的头文件:
第二段程序包含的头文件:
那么,在实际使用中,这两种方式有什么不同?哪种方式更容易上手,更方便快速开发呢?

使用特权

评论回复
地板
dirtwillfly|  楼主 | 2019-9-25 20:48 | 只看该作者
这里就要说说msp432的driverlib和SimpleLink MSP432P4 SDK的特性。
msp432的driverlib:
In addition
to being able to control the MSP432 peripherals, DriverLib also gives the user the ability to use
common ARM peripherals such as the Interrupt (NVIC) and Memory Protection Unit (MPU) as well
as MSP430 peripherals such as the eUSCI Serial peripherals and Watchdog Timer (WDT).
在驱动库的手册里,对msp432的驱动库做了如上描述。也就是说msp432的driverlib使用起来和msp430的驱动库一样。msp432和msp430的驱动库有相似的api函数名和类似的使用方法。对于用惯了msp430的用户来说,使用msp432会非常方便。

使用特权

评论回复
5
dirtwillfly|  楼主 | 2019-9-25 20:49 | 只看该作者
SimpleLink MSP432P4 SDK:
SimpleLink是ti近几年新推出的一个平台。
提供最广泛的有线和无线 Arm® MCU(片上系统)产品系列,通过这一个环境即可为物联网和汽车应用提供灵活的硬件、软件和工具选项。
意思就是ti整个SimpleLink系列,包含蓝牙、zigbee、wifi等都统一在了一起。用官网的一个图最能说明这个问题:
SimpleLink统一了有线和无线平台,代码100%可移植性,完整物联网应用的安全性,还有终极的低功耗性能。
SimpleLink还提供了丰富的SDK plug-ins,还有可选的OS,和中间件,并包含了driverlib。driverlib是SimpleLink中的一部分。

使用特权

评论回复
6
dirtwillfly|  楼主 | 2019-9-25 20:49 | 只看该作者
总之:
1、如果是从msp430转到msp432的人员,和新入门的网友,可以先使用driverlib,然后慢慢熟悉SimpleLink。
2、如果有一定基础,建议尽早开始熟悉SimpleLink。SimpleLink是未来的趋势,是在不同物联网连接方式间快速切换的利器。

使用特权

评论回复
7
aoyi| | 2019-10-13 08:46 | 只看该作者
非常感谢楼主分享

使用特权

评论回复
8
kxsi| | 2019-10-13 10:23 | 只看该作者
非常好的资料

使用特权

评论回复
9
qcliu| | 2019-10-13 11:05 | 只看该作者
非常不错的分享

使用特权

评论回复
10
zljiu| | 2019-10-13 11:36 | 只看该作者
非常感谢楼主分享

使用特权

评论回复
11
coshi| | 2019-10-13 11:52 | 只看该作者
非常感谢楼主分享

使用特权

评论回复
12
晓伍| | 2019-10-13 12:08 | 只看该作者
代码很清楚

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:欢迎进入TI MCU论坛      21ic TI技术交流1群:61549143(已满),  21ic TI技术交流2群:311421422 我的博客:http://blog.timcu.com/

1179

主题

34676

帖子

1115

粉丝