MSP432学习01--新建keil空工程

        为了准备电赛和深入学习嵌入式编程为后面研究FOC电机驱动做准备,入手了一块TI的MSP432P4开发板,在这里开一个系列博文来记录学习过程方便复习:

        首先是在keil里创建新工程项目,因为之前的项目用的都是keil开发平台,所以这次准备创建一个空工程以备使用,折腾了两天晚上才创建出来,遇到了一个很脑残的问题(后面会说)

        第一步先下载官方的关于MSP432的驱动库(simplelink),在官网可以轻松搜到,我就不放链接了。解压后长这样:

 

        

         第二步是创建自己的工程文件夹如图,像我这里创建的是MSP432_EMPTY,里面包含了hardware、library、system、project四个子文件夹。其中hardware文件夹存放自己编写的外设相关的一些.c、.h文件,library文件夹放官方的驱动库,system文件夹放自己编写的与系统有关的文件,project放keil工程文件。

        

 

        hardware和sys目前可以不管。

        把之前解压的驱动库文件中的source/thirdparty中的CMSIS(第三方协议文件)和source里面的ti文件夹一起放在library里面。(为了减小文件体积,可以将ti文件夹里面只保留devices文件夹)

        simplelink_msp432p4_sdk_3_40_01_02\source\ti\devices\msp432p4xx\startup_system_files里面找到system_msp432p401r,和main.c一起放在文件夹外面。                  simplelink_msp432p4_sdk_3_40_01_02\source\ti\devices\msp432p4xx\startup_system_files\keil里面找到startup_msp432p401r_uvision.s文件,放到project文件夹里。

        第三步创建keil新工程,一般的创建方法应该都已经掌握,这里只提需要注意的点:

                1.这个界面勾选

                 2.新建.c、.h文件并添加文件组,添加完后效果如图:

 

                 其中msp432p4xx_driverlib.lib文件在相对路径ti\devices\msp432p4xx\driverlib\keil里面找到,有了这个文件不同于之前将全部文件都添加进工程,优点是不用频繁的include大量头文件,只用#include <ti/devices/msp432p4xx/driverlib/driverlib.h>(相对路径不能变!),而且编译速度变快很多,缺点是在工程内无法通过goto到达相应函数,建议在对驱动库函数比较熟悉之后这样做。

                3.配置项目属性:

                主要注意C/C++这个选项卡。Define里面添加__MSP432P401R__,__TARGET_FPU_VFP,__FPU_PRESENT,ARM_MATH_CM4,optimization选择level 2,C99 mode一定要勾上。

                 debug选项卡里面要选择对应的下载器,这里我用的是CMSIS-DAPPER。

                 最后添加Include Path,添加完效果如图:

        

                        4.创建完成,在main.c里面添加代码,编译成功后即可下载运行。没有现象不用害怕,每次下载后需要按一下开发板上的reset键才会运行!当时就是在这个地方卡了几个小时。

结语

           首先第一次写博文,肯定有很多疏漏,希望大家多多指教!

            然后是在此鸣谢b站@m-RNA,我的工程文件大部分参考于他,他在b站有MSP432的快速入门视频和相应资料:MSP432P4电赛入门速成/Keil/CCS/VScode_哔哩哔哩_bilibili

            最后本文主要是为了方便我的记忆,所以没有太多原理性的文字,原理性的可以参考从零建立独立的MSP432 KEIL工程 - 哔哩哔哩

            下一节将是关于一些简单库函数(有关于板载led和板载按键的控制)的创建和验证的。

MSP432 低功耗高性能并存10.1 Digital I/O Introduction The digital I/O features include: • Independently programmable individual I/Os • Any combination of input or output • Individually configurable interrupts for ports (available for certain ports only) • Independent input and output data registers • Individually configurable pullup or pulldown resistors • Wake-up capability from ultra-low power modes (available for certain ports only) • Individually configurable high drive I/Os (available for certain I/Os only) Devices within the family may have up to eleven digital I/O ports implemented (P1 to P10 and PJ). Most ports contain eight I/O lines; however, some ports may contain less (see the device-specific data sheet for ports available). Each I/O line is individually configurable for input or output direction, and each can be individually read or written. Each I/O line is individually configurable for pullup or pulldown resistors. Certain ports have interrupt and wake-up capability from ultra-low power modes (see device specific data sheet for ports with interrupt and wake-up capability). Each interrupt can be individually enabled and configured to provide an interrupt on a rising or falling edge of an input signal. All interrupts are fed into an encoded Interrupt Vector register, allowing the application to determine which sub-pin of a port has generated the event. Individual ports can be accessed as byte-wide ports or can be combined into half-word-wide ports. Port pairs P1 and P2, P3 and P4, P5 and P6, P7 and P8, and so on, are associated with the names PA, PB, PC, PD, and so on, respectively. All port registers are handled in this manner with this naming convention. The main exception are the interrupt vector registers, for example, interrupts for ports P1 and P2 must be handled through P1IV and P2IV, PAIV does not exist. When writing to port PA with half-word operations, all 16 bits are written to the port. When writing to the lower byte of port PA using byte operations, the upper byte remains unchanged. Similarly, writing to the upper byte of port PA using byte instructions leaves the lower byte unchanged. When writing to a port that contains less than the maximum number of bits possible, the unused bits are don't care. Ports PB, PC, PD, PE, and PF behave similarly.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值