**Qinheng CH32V307VCT6 [minimum system](https://blog.zeruns.tech/tag/最低系统) board, leads out all IO ports, a Type-C connected to the USB2.0 full-speed OTG interface, a Flash chip model W25Q64 with a capacity of 64Mbit connected to the SPI2 interface, and a TL432 voltage reference 1.25V (measured about 1.246V) on the board can be connected to AD13 of PC3 through a jumper, and a 3.29V reference can be connected to the ADC reference voltage VREF through a 0 ohm resistor. **
- I drew a minimum system board for MSP430F149 and made it open source: [https://blog.zeruns.tech/archives/713.html](https://blog.zeruns.tech/archives/713.html)
- STM32F030C8T6 minimum system board and running lights (schematic diagram and PCB): [https://blog.zeruns.tech/archives/715.html](https://blog.zeruns.tech/archives/715.html)
## Introduction to CH32V307VCT6
The CH32V series is an industrial-grade general-purpose microcontroller designed based on the 32-bit RISC-V of Qingke. The entire series of products has added hardware stack area, fast interrupt entry and other designs, which greatly improves the interrupt response speed compared to the standard. The CH32V303_305_307 series is equipped with the V4F core, supports single-precision floating-point instruction set, and has higher computing performance. In terms of product functions, it supports 144MHz main frequency zero-wait operation, and provides unique resource structures according to different application directions, such as 8 groups of USART/UART serial ports, 4 groups of motor timers, USB2.0 high-speed interface (480Mbps) with built-in PHY transceiver, Gigabit Ethernet MAC, etc.
Qinheng official website product introduction: [https://url.zeruns.tech/Hcd8p](https://url.zeruns.tech/Hcd8p)
Free sample application address (freight to be paid): [https://url.zeruns.tech/x67TF](https://url.zeruns.tech/x67TF)
Chip data sheet download address: [https://url.zeruns.tech/hDzqw](https://url.zeruns.tech/hDzqw) Extraction code: cn7c
## Actual picture
![1688143821239.gif]

![IMG_5720.jpg]

![IMG_5724.jpg]

![IMG_5725.JPG]

![IMG_5727.jpg]

## Schematic diagram
![SCH_Schematic1_1-P1_2023-07-01.png]

## PCB
**Top layer:**
The 1.25V (measured about 1.246V) voltage reference of TL432 can be connected to the ADC13 interface of GPIOPC3 through the H8 jumper cap.
SW3 controls the BOOT0 and 1 bootstrap pins, and can set the bootstrap mode (see the chip manual 2.5.2 on-chip memory and bootstrap mode for details). Just set them to low level (off).
The H9 pin header is used to connect the WCH-Link burning code.
The H5 pin header is used to select the power supply of the VBAT pin. If there is no battery inserted, it can be connected to the 3.3V power supply through the jumper cap. If a battery is inserted, it can be connected to BAT.
![2023-07-01_03-35-06.png]

**Bottom layer:**
![2023-07-01_03-35-19.png]

**If external VDDA power supply and VREF are not required, connect R11 and R7 on the bottom to 0 ohm resistors, and then VREF+ can be connected to the 3.3V power supply stepped down by LDO or the 3.29V reference voltage output by TL432 through R8 and R9. Normally, R9 can be connected and the other one can be left empty. **
## Component purchase address
** Component purchase is recommended at LiChuang Mall, preferential registration link: [https://activity.szlcsc.com/invite/D03E5B9CEAAE70A4.html](https://activity.szlcsc.com/invite/D03E5B9CEAAE70A4.html)** **
All components on the board can be purchased at LiChuang Mall. Click the BOM table below to place an order at LiChuang Mall and import the components used into the shopping cart with one click. **
## Example code
** Complete project download address: [https://blog.zeruns.tech/archives/726.html](https://blog.zeruns.tech/archives/726.html)**
The example uses the Harmony LiteOS-M system. Three tasks are built in the example, namely: LED2 flashes once every 500ms, LED3 flashes once every 1 second, and LED4 flashes once every 2 seconds. (The above animation speed is 1.5 times faster)
The project should be opened with MounRiver Studio software.
**main.c code:**
```c
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "debug.h"
#include "los_tick.h"
#include "los_task.h"
#include "los_config.h"
#include "los_interrupt.h"
#include "los_debug.h"
#include "los_compiler.h"
/* Global define */
/* Global Variable */
__attribute__((aligned (8))) UINT8 g_memStart[LOSCFG_SYS_HEAP_SIZE];
UINT32 g_VlaueSp=0;
u8 i = 0,j=0,k=0;
/*********************************************************************
* @fn taskSampleEntry3
*
* @brief taskSampleEntry3 program.
*
* @return none
*/
VOID taskSampleEntry3(VOID)
{
while(1) {
LOS_TaskDelay(2000);
printf("taskSampleEntry3 running,task3 SP:%08x
",__get_SP());
GPIO_WriteBit(GPIOD, GPIO_Pin_13, (k == 0) ? (k = Bit_SET) : (k = Bit_RESET));
}
}
/*********************************************************************
* @fn taskSampleEntry2
*
* @brief taskSampleEntry2 program.
*
* @return none
*/
VOID taskSampleEntry2(VOID)
{
while(1) {
LOS_TaskDelay(1000);
printf("taskSampleEntry2 running,task2 SP:%08x
",__get_SP());
GPIO_WriteBit(GPIOD, GPIO_Pin_12, (j == 0) ? (j = Bit_SET) : (j = Bit_RESET));
}
}
/*********************************************************************
* @fn taskSampleEntry1
*
* @brief taskSampleEntry1 program.
*
* @return none
*/
VOID taskSampleEntry1(VOID)
{
while(1) {
LOS_TaskDelay(500);
printf("taskSampleEntry1 running,task1 SP:%08x
",__get_SP());
GPIO_WriteBit(GPIOD, GPIO_Pin_11, (i == 0) ? (i = Bit_SET) : (i = Bit_RESET));
}
}
// https://blog.zeruns.tech
/*********************************************************************
* @fn EXTI0_INT_INIT
*
* @brief Initializes EXTI0 collection.
*
* @return none
*/
void EXTI0_INT_INIT(void)
{
GPIO_InitTypeDef GPIO_InitStructure={0};
EXTI_InitTypeDef EXTI_InitStructure={0};
NVIC_InitTypeDef NVIC_InitStructure={0};
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO|RCC_APB2Periph_GPIOA,ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_Init(GPIOA, &GPIO_InitStructure);
/* GPIOA ----> EXTI_Line0 */
GPIO_EXTILineConfig(GPIO_PortSourceGPIOA,GPIO_PinSource0);
EXTI_InitStructure.EXTI_Line=EXTI_Line0;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 4;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
void GPIO_INIT(void) {
GPIO_InitTypeDef GPIO_InitStructure = { 0 };
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12|GPIO_Pin_11|GPIO_Pin_13;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOD, &GPIO_InitStructure);
}
/*********************************************************************
* @fn taskSample
*
* @brief taskSample program.
*
* @return none
*/
UINT32 taskSample(VOID) {
UINT32 uwRet;
UINT32 taskID1, taskID2, taskID3;
TSK_INIT_PARAM_S stTask = { 0 };
stTask.pfnTaskEntry = (TSK_ENTRY_FUNC) taskSampleEntry1;
stTask.uwStackSize = 0X500;
stTask.pcName = "taskSampleEntry1";
stTask.usTaskPrio = 6;/* 高优先级 */
uwRet = LOS_TaskCreate(&taskID1, &stTask);
if (uwRet != LOS_OK) {
printf("create task1 failed
");
}
stTask.pfnTaskEntry = (TSK_ENTRY_FUNC) taskSampleEntry2;
stTask.uwStackSize = 0X500;
stTask.pcName = "taskSampleEntry2";
stTask.usTaskPrio = 7;/* 低优先级 */
uwRet = LOS_TaskCreate(&taskID2, &stTask);
if (uwRet != LOS_OK) {
printf("create task2 failed
");
}
stTask.pfnTaskEntry = (TSK_ENTRY_FUNC) taskSampleEntry3;
stTask.uwStackSize = 0X500;
stTask.pcName = "taskSampleEntry3";
stTask.usTaskPrio = 7;/* 低优先级 */
uwRet = LOS_TaskCreate(&taskID3, &stTask);
if (uwRet != LOS_OK) {
printf("create task3 failed
");
}
// https://blog.vpszj.cn
EXTI0_INT_INIT();
return LOS_OK;
}
/*********************************************************************
* @fn main
*
* @brief Main program.
*
* @return none
*/
LITE_OS_SEC_TEXT_INIT int main(void)
{
unsigned int ret;
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);
SystemCoreClockUpdate();
Delay_Init();
GPIO_INIT();
USART_Printf_Init(115200);
printf("SystemClk:%d
",SystemCoreClock);
printf( "ChipID:%08x
", DBGMCU_GetCHIPID() );
ret = LOS_KernelInit();
taskSample();
if (ret == LOS_OK)
{
LOS_Start();
}
GPIO_WriteBit(GPIOC, GPIO_Pin_1,RESET);
while (1) {
__asm volatile("nop");
}
}
/*********************************************************************
* @fn EXTI0_IRQHandler
*
* @brief This function handles EXTI0 Handler. the thread stack will not be filled and overflowed. However, with the current method, when the thread enters the interrupt, the 16 caller registers saved by the compiler are still pushed into the thread stack. If you need /* The interrupt stack uses the value set by the original call to main, separating the interrupt stack and the thread stack. In this way, when the thread jumps to the interrupt, if the interrupt function is nested deeply,{void EXTI0_IRQHandler(void)void EXTI0_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));*/* @return none
*
* If the caller register is pushed into the interrupt stack, the entry and exit of the interrupt function need to be assembled, and the user interrupt processing function can be called in the middle. For details, see
the ipq_entry example in los_exc.S
* */
GET_INT_SP();
HalIntEnter();
if(EXTI_GetITStatus(EXTI_Line0)!=RESET)
{
g_VlaueSp= __get_SP();
printf("Run at EXTI:");
printf("interruption sp:%08x
",g_VlaueSp);
HalDisplayTaskInfo();
EXTI_ClearITPendingBit(EXTI_Line0); /* Clear Flag */
}
HalIntExit();
FREE_INT_SP();
}
```
## Other open source project
recommendations- SY8205 synchronous buck adjustable DCDC power module (schematic diagram and PCB): [https://blog.zeruns.tech/archives/717.html](https://blog.zeruns.tech/archives/717.html)
- 2011 National Electric Competition Topic - Switching Power Supply Module Parallel Power Supply System: [https://blog.zeruns.tech/archives/718.html](https://blog.zeruns.tech/archives/718.html)
- 2007 Electric Competition Power Supply Topic: 30 to 36V Adjustable Boost DCDC Module (UC3843): [https://oshwhub.com/zeruns/36v-sheng-ya-dcdc-mo-kuai-uc3842](https://oshwhub.com/zeruns/36v-sheng-ya-dcdc-mo-kuai-uc3842)
- STC12C5A60S2 minimum system board/51 MCU temperature display and temperature control fan: [https://blog.zeruns.tech/archives/721.html](https://blog.zeruns.tech/archives/721.html)
- STM32F407 standard library project template with U8g2 graphics library transplanted: [https://blog.zeruns.tech/archives/722.html](https://blog.zeruns.tech/archives/722.html)