这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » 企业专区 » TI » 【MSP焕新大作战】课程1+任务1

共2条 1/1 1 跳转至

【MSP焕新大作战】课程1+任务1

菜鸟
2024-07-03 11:03:41     打赏

实现点亮RGB,实现红绿蓝循环显示

通过查看硬件电路图我们得知

PA13接绿灯

PA26接红灯

PA27接蓝灯

且保证硬件J3 J12 J13短接

且   PA13    PA26   PA27为高电平时,点亮


软件代码如下

#include "ti_msp_dl_config.h"


/* This results in approximately 0.5s of delay assuming 32MHz CPU_CLK */

#define DELAY (16000000)

void red_flash()

{

    DL_GPIO_setPins(GPIO_LEDS_PORT, GPIO_LEDS_USER_LED_2_PIN);

    delay_cycles(DELAY);

    DL_GPIO_clearPins(GPIO_LEDS_PORT, GPIO_LEDS_USER_LED_2_PIN);

}

void green_flash()

{

    DL_GPIO_setPins(GPIO_LEDS_PORT, GPIO_LEDS_USER_LED_3_PIN);

    delay_cycles(DELAY);

    DL_GPIO_clearPins(GPIO_LEDS_PORT, GPIO_LEDS_USER_LED_3_PIN);

}

void blue_flash()

{

    DL_GPIO_setPins(GPIO_LEDS_PORT, GPIO_LEDS_USER_LED_1_PIN);

    delay_cycles(DELAY);

    DL_GPIO_clearPins(GPIO_LEDS_PORT, GPIO_LEDS_USER_LED_1_PIN);

}

int main(void)

{

    /* Power on GPIO, initialize pins as digital outputs */

    SYSCFG_DL_init();


    while (1) {

        /*

         * Call togglePins API to flip the current value of LEDs 1-3. This

         * API causes the corresponding HW bits to be flipped by the GPIO HW

         * without need for additional R-M-W cycles by the processor.

         */


        red_flash();

        green_flash();

        blue_flash();

    }

}

演示视频

https://www.bilibili.com/video/BV1GBhqehEM7/?vd_source=4f8f0092a0967d5a44cc4790809b35be


高工
2024-07-03 12:56:03     打赏
2楼

谢谢分享


共2条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]