1硬件原理
芯片的datasheet中 有介绍拉电流的最大额定值
I/O 类型:ODIO = 5V 容限开漏,SDIO = 标准驱动,HSIO = 高速
如上原理图LED2 的 RGB 分别通过拉电流的方式连接到了PA13PA26, PA27引脚上。
通过编写程序控制以上引脚输出高低电平配合延时程序实现RGB灯的循环显示
2关键软件代码
引脚定接口定义头文件
/* Port definition for Pin Group RGB_PORT */ #define RGB_PORT_PORT (GPIOA) /* Defines for LED_RED: GPIOA.26 with pinCMx 27 on package pin 30 */ #define RGB_PORT_LED_RED_PIN (DL_GPIO_PIN_26) #define RGB_PORT_LED_RED_IOMUX (IOMUX_PINCM27) /* Defines for LED_GREEN: GPIOA.13 with pinCMx 14 on package pin 17 */ #define RGB_PORT_LED_GREEN_PIN (DL_GPIO_PIN_13) #define RGB_PORT_LED_GREEN_IOMUX (IOMUX_PINCM14) /* Defines for LED_BLUE: GPIOA.27 with pinCMx 28 on package pin 31 */ #define RGB_PORT_LED_BLUE_PIN (DL_GPIO_PIN_27) #define RGB_PORT_LED_BLUE_IOMUX (IOMUX_PINCM28) /* clang-format on */ void SYSCFG_DL_init(void); void SYSCFG_DL_initPower(void); void SYSCFG_DL_GPIO_init(void); void SYSCFG_DL_SYSCTL_init(void);
初始化时钟以及引脚
SYSCONFIG_WEAK void SYSCFG_DL_init(void) { SYSCFG_DL_initPower(); SYSCFG_DL_GPIO_init(); /* Module-Specific Initializations*/ SYSCFG_DL_SYSCTL_init(); }
main函数实现
#include "ti_msp_dl_config.h" int main(void) { SYSCFG_DL_init(); while (1) { DL_GPIO_setPins(RGB_PORT_PORT, RGB_PORT_LED_RED_PIN ); DL_GPIO_clearPins(RGB_PORT_PORT, RGB_PORT_LED_GREEN_PIN | RGB_PORT_LED_BLUE_PIN); delay_cycles(32000000); DL_GPIO_setPins(RGB_PORT_PORT, RGB_PORT_LED_GREEN_PIN ); DL_GPIO_clearPins(RGB_PORT_PORT, RGB_PORT_LED_RED_PIN | RGB_PORT_LED_BLUE_PIN); delay_cycles(32000000); DL_GPIO_setPins(RGB_PORT_PORT, RGB_PORT_LED_BLUE_PIN ); DL_GPIO_clearPins(RGB_PORT_PORT, RGB_PORT_LED_RED_PIN | RGB_PORT_LED_GREEN_PIN); delay_cycles(32000000); } }
3实验结果