บทความนี้จะมาสอนวิธีการติดตั้งและใช้งาน CH32V003 บน PlatformIO กัน โดยที่ใช้งานผ่าน VSCODE ที่ติดตั้ง Platform ที่ชื่อ WCH CH32V เข้าไปในระบบ ก็จะทำให้สามารถเขียน CH32V003 ผ่าน PlatformIO ได้อย่างง่ายๆ เป็น OpenSource ที่

วิธีการติดตั้ง
ในการติดตั้งจะต้องลง VSCODE และ PIO ให้เรียบร้อยก่อนจากนั้นก็เพิ่ม Platform ของ WCH CH32V เข้ามาในระบบได้เลย โดยมี URL Install :
https://github.com/Community-PIO-CH32V/platform-ch32v.git

เมื่อติดตั้งเรียบร้อยจะมีรายการที่ชื่อ WCH CH32V ขึ้นมา

ตัวอย่างการใช้งาน
หลังจากติดตั้ง Platform เรียบร้อยแล้วก็สามารถสร้าง Project ที่เกี่ยวข้องกับ WCH CH32V003 ได้โดยตรง และ สามารถใช้ WCH LinkE 1v3 upload file เข้า MCU ได้ตามปกติ

ตัวอย่าง code ไฟกระพริบ
#include "debug.h" /********************************************************************* * @fn GPIO_Toggle_INIT * @brief Initializes GPIOA.0 * @return none */ void GPIO_Toggle_INIT(void) { GPIO_InitTypeDef GPIO_InitStructure = {0}; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOC, &GPIO_InitStructure); } /********************************************************************* * @fn main * @brief Main program. * @return none */ int main(void) { u8 i = 0; NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); Delay_Init(); Delay_Ms(2000); USART_Printf_Init(115200); printf("SystemClk:%d\r\n", SystemCoreClock); printf("GPIO Toggle RUNING\r\n"); GPIO_Toggle_INIT(); while(1) { Delay_Ms(100); GPIO_WriteBit(GPIOC, GPIO_Pin_4, (i == 0) ? (i = Bit_SET) : (i = Bit_RESET)); } }


CH32V003 : https://shopee.co.th/witawat57/23167328296
สนับสนุนร้านค้าของเรา เพื่อจะได้เป็นกำลังใจเขียนบทความใหม่ๆ