实现点亮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