Open
Description
CH32V003F4U6, nanoCHV32003 v1.0
If the user tries to set uart_config.baudrate above 500_000, the USART still only transmits at 500kbaud. Datasheet and usart/mod.rs indicate 3 Mbps should be possible. It may be a clocking problem with my usage of hal::Config::default().
#![no_std]
#![no_main]
#![feature(type_alias_impl_trait)]
use embassy_executor::Spawner;
use embassy_time::Timer;
use hal::gpio::{AnyPin, Level, Output, Pin};
//use hal::println;
use ch32_hal::usart::UartTx;
use {ch32_hal as hal, panic_halt as _};
use heapless::String;
#[embassy_executor::task]
async fn blink(pin: AnyPin, interval_ms: u64) {
let mut led = Output::new(pin, Level::Low, Default::default());
loop {
led.set_high();
Timer::after_millis(interval_ms).await;
led.set_low();
Timer::after_millis(interval_ms).await;
}
}
#[embassy_executor::main(entry = "qingke_rt::entry")]
async fn main(spawner: Spawner) -> ! {
let p = hal::init(hal::Config::default());
hal::embassy::init();
let mut uart_config: ch32_hal::usart::Config = Default::default();
uart_config.baudrate = 500000;
let mut uart = UartTx::new_blocking(p.USART1, p.PD0, uart_config).unwrap();
// Adjust the LED GPIO according to your board
spawner.spawn(blink(p.PD6.degrade(), 100)).unwrap();
loop {
Timer::after_millis(100).await;
uart.blocking_write(b"Hello world!\r\n").unwrap();
}
}
Metadata
Assignees
Labels
No labels