(Text written by Google's AI, Gemini helped me do the tests)
Describe the bug
The YD-CH32V307VCT6 development board (which features an 8MHz external crystal) fails to execute any code (e.g., Blink) when compiled via Arduino IDE or VS Code/PlatformIO, even though the upload/verify process completes successfully. The board only works when using the manufacturer's IDE (MounRiver Studio).
Hardware Environment:
Board: YD-CH32V307VCT6 (link below).
MCU: CH32V307VCT6.
External Crystal (HSE): 8MHz.
LED Pins: PA15 (LED1), PB4 (LED2).
Observed Behavior:
VS Code / PlatformIO: Upload is successful (Verified OK), but the MCU seems to hang immediately after reset. No GPIO activity (PA15, PB4, or Ethernet LEDs PC0/PC1) is observed.
Arduino IDE 2.x: Same behavior as PlatformIO. Code is flashed but the board remains unresponsive.
Steps to Reproduce:
Create a simple Blink sketch for PA15/PB4.
Compile and upload using the standard genericCH32V307VCT6 board definition.
Observe that the board does not boot/blink.
Additional Context (Pinout Used):
LED1: PA15 (JTAG Pin)
LED2: PB4 (JTAG Pin)
Ethernet LEDs: PC0, PC1
Sketch:
#include <Arduino.h>
// Using the pattern suggested by the compiler:
#define LED1 PA_15
#define LED2 PB_4
#define LED_LINK PC_0
#define LED_ACT PC_1
void setup() {
// 1. Forces a system clock reset to ensure stability
// This helps if the 8MHz crystal is slow to rise
delay(200);
// 2. Enables the clock for peripherals and AFIO (necessary for Remap)
// RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB |
// RCC_APB2Periph_GPIOC | RCC_APB2Periph_AFIO, ENABLE);
// RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB |
// RCC_APB2Periph_GPIOC, ENABLE);
// 3. Releases pins PA15 and PB4 for the JTAG function
// GPIO_PinRemapConfig(GPIO_Remap_SWJ_Disable, ENABLE);
// 4. Configure the pins
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(LED_LINK, OUTPUT);
pinMode(LED_ACT, OUTPUT);
}
void loop() {
// Test: Turn everything on for 1 second
digitalWrite(LED1, HIGH);
digitalWrite(LED2, HIGH);
digitalWrite(LED_LINK, HIGH);
digitalWrite(LED_ACT, HIGH);
delay(1000);
// Turn off everything for 1 second
digitalWrite(LED1, LOW);
digitalWrite(LED2, LOW);
digitalWrite(LED_LINK, LOW);
digitalWrite(LED_ACT, LOW);
delay(1000);
}
Working code for MounRiver Studio:
#include "debug.h"
// Definições de pinos baseadas no seu mapeamento [cite: 1]
#define LED1_PIN GPIO_Pin_15 // PA15 [cite: 1]
#define LED2_PIN GPIO_Pin_4 // PB4 [cite: 1]
void GPIO_Config(void) {
GPIO_InitTypeDef GPIO_InitStructure = {0};
// 1. Habilita o clock para os Portais A, B e a função de Remapeamento (AFIO)
// RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_AFIO, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB, ENABLE);
// 2. Libera PA15 e PB4 da função JTAG (Essencial para esses LEDs funcionarem)
// GPIO_PinRemapConfig(GPIO_Remap_SWJ_Disable, ENABLE);
// 3. Configura PA15 (LED1)
GPIO_InitStructure.GPIO_Pin = LED1_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; // Saída Push-Pull
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
// 4. Configura PB4 (LED2)
GPIO_InitStructure.GPIO_Pin = LED2_PIN;
GPIO_Init(GPIOB, &GPIO_InitStructure);
}
int main(void) {
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
Delay_Init();
GPIO_Config();
while(1) {
// Liga LEDs (Se for lógica inversa, use Reset para ligar)
GPIO_WriteBit(GPIOA, LED1_PIN, Bit_SET);
GPIO_WriteBit(GPIOB, LED2_PIN, Bit_RESET);
Delay_Ms(500);
// Desliga LEDs
GPIO_WriteBit(GPIOA, LED1_PIN, Bit_RESET);
GPIO_WriteBit(GPIOB, LED2_PIN, Bit_SET);
Delay_Ms(500);
}
}
Board:
https://www.cnx-software.com/2022/07/14/yd-ch32v307vct6-risc-v-mcu-board-comes-with-ethernet-and-plenty-of-i-os/
Thank you
(Text written by Google's AI, Gemini helped me do the tests)
Describe the bug
The YD-CH32V307VCT6 development board (which features an 8MHz external crystal) fails to execute any code (e.g., Blink) when compiled via Arduino IDE or VS Code/PlatformIO, even though the upload/verify process completes successfully. The board only works when using the manufacturer's IDE (MounRiver Studio).
Hardware Environment:
Board: YD-CH32V307VCT6 (link below).
MCU: CH32V307VCT6.
External Crystal (HSE): 8MHz.
LED Pins: PA15 (LED1), PB4 (LED2).
Observed Behavior:
VS Code / PlatformIO: Upload is successful (Verified OK), but the MCU seems to hang immediately after reset. No GPIO activity (PA15, PB4, or Ethernet LEDs PC0/PC1) is observed.
Arduino IDE 2.x: Same behavior as PlatformIO. Code is flashed but the board remains unresponsive.
Steps to Reproduce:
Create a simple Blink sketch for PA15/PB4.
Compile and upload using the standard genericCH32V307VCT6 board definition.
Observe that the board does not boot/blink.
Additional Context (Pinout Used):
LED1: PA15 (JTAG Pin)
LED2: PB4 (JTAG Pin)
Ethernet LEDs: PC0, PC1
Sketch:
Working code for MounRiver Studio:
Board:
https://www.cnx-software.com/2022/07/14/yd-ch32v307vct6-risc-v-mcu-board-comes-with-ethernet-and-plenty-of-i-os/
Thank you