本帖最后由 Charles2023 于 2023-11-20 17:30 编辑
板子收到了,点灯开光...
1. 打开AiPi-Open-Kits/aithinker_Ai-M6X_SDK/examples/peripherals/pwm_v2内的pwm_basic项目,修改main.c文件如下:
- #include "bflb_mtimer.h"
- #include "bflb_pwm_v2.h"
- #include "bflb_clock.h"
- #include "board.h"
- #include "bflb_gpio.h"
- struct bflb_device_s *pwm;
- void board_pwm_led_init()
- {
- struct bflb_device_s *gpio;
- gpio = bflb_device_get_by_name("gpio");
- // 红灯: GPIO_PIN_12, PWM_CH0
- // 绿灯: GPIO_PIN_14, PWM_CH2
- // 蓝灯: GPIO_PIN_15, PWM_CH3
- bflb_gpio_init(gpio, GPIO_PIN_14, GPIO_FUNC_PWM0 | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
- }
- int main(void)
- {
- board_init();
- board_pwm_led_init();
- pwm = bflb_device_get_by_name("pwm_v2_0");
- /* period = .XCLK / .clk_div / .period = 40MHz / 40 / 1000 = 1KHz */
- struct bflb_pwm_v2_config_s cfg = {
- .clk_source = BFLB_SYSTEM_XCLK,
- .clk_div = 40,
- .period = 1000,
- };
- bflb_pwm_v2_init(pwm, &cfg);
- bflb_pwm_v2_start(pwm);
- uint16_t high_threhold = 200;
- while (1) {
- printf("pwm basic running\r\n");
- bflb_pwm_v2_channel_positive_start(pwm, PWM_CH2);
- for (size_t i = high_threhold; i >0; i--)
- {
- bflb_pwm_v2_channel_set_threshold(pwm, PWM_CH2, i, high_threhold);
- bflb_mtimer_delay_ms(10);
- }
- for (size_t i = 1; i < high_threhold; i++)
- {
- bflb_pwm_v2_channel_set_threshold(pwm, PWM_CH2, i, high_threhold);
- bflb_mtimer_delay_ms(10);
- }
- bflb_pwm_v2_channel_positive_stop(pwm, PWM_CH2);
- }
- }
复制代码 2. 连接数据线,打开设备管理器查看com端口号为COM5(各设备端口不一定相同):
3. 按住烧录键后点按重置键
4. 在当前目录打开git-bash,输入以下命令(注:COM5为在设备管理器看到的端口号,按实际修改):
- make flash CHIP=bl616 COMX=COM5
复制代码
5. 控制台输出All Success表示烧录成功
6. 点按重置键,呼吸灯点亮:
前期帖子:
【板子申请】Ai-M61-32S开发环境搭建一键脚本win
http://bbs.ai-thinker.com/forum.php?mod=viewthread&tid=43075
(出处: 物联网开发者社区-安信可论坛)
【板子开箱】Ai-M61-32S-Kit顺丰包邮零元购
http://bbs.ai-thinker.com/forum.php?mod=viewthread&tid=43377
(出处: 物联网开发者社区-安信可论坛)
|
|