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.

MSP432P401R Launchpad开箱与初评

其实在板子还没到手之前,就已经在官网下载了相关资料。包括SDK及KEIL的DFP包还有板子的硬件设计资料。

这里贴一下相关连接:

SimpleLink MCU SDK User's Guide

software-dl.ti.com/.../Users_Guide.html

CCS
 software-dl.ti.com/.../ccs_downloads.html

SDK

www.ti.com/.../SIMPLELINK-MSP432-SDK

板子到手后,因为家里电脑之前有装KEIL,最开始是想用CCS的,后来电脑有点卡,就没装了,还是继续用KEIL。

首先吧DFP包安装上,

这里能选到就行了。

在然后,好像是驱动版本的问题。Launchpad上面的XDS仿真器不能用,所以我只能用跳帽然后接Jlink了。

开关要拨到右边

然后keil里面可以找到芯片了

板子插电后的默认代码是闪灯。这个灯真的好刺眼啊,干太亮了。于是找了下原理图一看,对应的三色LED限流电阻都好小。

感觉放桌子上太刺眼了,于是想把灯弄暗一点。

这个是改了之后了,我把R2,R3,R4都改成2K的了。反正能亮看得到就行

本来硬件一切都就绪,KEIL也能连接设备之后,里面打开例程。翻到主函数,想来修改下代码一边学习。

可是。。。。。。。。

TI的官方把外设的库都封装好了,看不到源代码。找到一个函数,想去看这个函数的原型和使用方法,根本就是看不到啊,这可如何下手!!!

上面图片是自带demo的例程。看最左边有个msp432p4xx_driverlib.lib,这个就是官方已经封装好的库。

工程已经编译好了,工程的browse information也勾上了。但是我想看 GPIO_setAsOutputPin这个函数的原型和使用方法,就会看不到。

这个就很不方便了。想要好好用的话,还得去官方看芯片的编程手册。有点不太习惯了。可能要等到有空的时候,再好好学习下吧。

另外请问一下坛友,P401R的ADC到底是16bit还是14bit的啊?

我看官方手册好像都写16bit,但是代码里面都是写的ADC14.

之前G2系列是10bit的ADC,代码就是ADC10。

  • //*****************************************************************************
    //
    //! \brief This function configures the selected Pin as output pin
    //!
    //! This function selected pins on a selected port as output pins.
    //!
    //! \param selectedPort is the selected port.
    //!        Valid values are:
    //!        - \b GPIO_PORT_P1
    //!        - \b GPIO_PORT_P2
    //!        - \b GPIO_PORT_P3
    //!        - \b GPIO_PORT_P4
    //!        - \b GPIO_PORT_P5
    //!        - \b GPIO_PORT_P6
    //!        - \b GPIO_PORT_P7
    //!        - \b GPIO_PORT_P8
    //!        - \b GPIO_PORT_P9
    //!        - \b GPIO_PORT_P10
    //!        - \b GPIO_PORT_P11
    //!        - \b GPIO_PORT_PJ
    //! \param selectedPins is the specified pin in the selected port.
    //!        Mask value is the logical OR of any of the following:
    //!        - \b GPIO_PIN0
    //!        - \b GPIO_PIN1
    //!        - \b GPIO_PIN2
    //!        - \b GPIO_PIN3
    //!        - \b GPIO_PIN4
    //!        - \b GPIO_PIN5
    //!        - \b GPIO_PIN6
    //!        - \b GPIO_PIN7
    //!        - \b GPIO_PIN8
    //!        - \b GPIO_PIN9
    //!        - \b GPIO_PIN10
    //!        - \b GPIO_PIN11
    //!        - \b GPIO_PIN12
    //!        - \b GPIO_PIN13
    //!        - \b GPIO_PIN14
    //!        - \b GPIO_PIN15
    //!
    //! Modified bits of \b PxDIR register and bits of \b PxSEL register.
    //!
    //! \return None
    //
    //*****************************************************************************
    extern void GPIO_setAsOutputPin(uint_fast8_t selectedPort,
            uint_fast16_t selectedPins);

  • void GPIO_setAsOutputPin(uint_fast8_t selectedPort, uint_fast16_t selectedPins)
    {
        uint32_t baseAddress = GPIO_PORT_TO_BASE[selectedPort];
    
        HWREG16(baseAddress + OFS_LIB_PASEL0) &= ~selectedPins;
        HWREG16(baseAddress + OFS_LIB_PASEL1) &= ~selectedPins;
        HWREG16(baseAddress + OFS_LIB_PADIR) |= selectedPins;
    }
    
    
    void GPIO_setAsInputPin(uint_fast8_t selectedPort, uint_fast16_t selectedPins)
    {
        uint32_t baseAddress = GPIO_PORT_TO_BASE[selectedPort];
    
        HWREG16(baseAddress + OFS_LIB_PASEL0) &= ~selectedPins;
        HWREG16(baseAddress + OFS_LIB_PASEL1) &= ~selectedPins;
        HWREG16(baseAddress + OFS_LIB_PADIR) &= ~selectedPins;
        HWREG16(baseAddress + OFS_LIB_PAREN) &= ~selectedPins;
    }

  • 封装好的库,也是可以找到源文件的,在C:\ti\simplelink_msp432p4_sdk_3_20_00_06\source\ti\devices\msp432p4xx\driverlib下面的.c和.h文件在一起的。