openwch / ch32v003

CH32V003 is an ultra-cheap RISC-V MCU with 2KB SRAM, 16KB flash, and up to 18 GPIOs that sells for under $0.10
393 stars 58 forks source link

Documentation: CH32V003RM.PDF v1.4: Does not match with physical device settings #17

Open siuyin opened 1 year ago

siuyin commented 1 year ago

The reference manual: http://www.wch-ic.com/downloads/CH32V003RM_PDF.html
Section 3.4 Register description (page 17 on v1.4) states
R32_RCC_CFGR0 has a reset value of 0x00000000.

This is incorrect. On a physical device, the reset value was found to be 0x00000020.

Please update the documentation or issue an errata for the CH32V003 part.

qiyongshuang commented 1 year ago

What method are you using to read the registers? I read it 0X00000000

siuyin commented 1 year ago

The clock frequency immediately after reset should be 24MHz but the batch of CH32V003 chips I have run at 8MHz.

qiyongshuang commented 1 year ago

Did you see the print or the MCO pin? Which CH32V003 chip do you use? I use ch32V003F4P6 do not have the problem .Do you use our EVT as test project?

siuyin commented 1 year ago

I used CH32V003F4P6 and measured system clock frequency by switching an LED on and off with a logic analyser. This is the test code I used:https://github.com/siuyin/ch32v003fun/blob/871a7350aac339c28b52cc4c08f3cd86e4bc2701/examples/minimal_blink/minimal_blink.c#L41

The setup code is: https://github.com/siuyin/ch32v003fun/blob/871a7350aac339c28b52cc4c08f3cd86e4bc2701/ch32v003fun/ch32v003fun.c#L766

SETUP_SYSTICK_HCLK is: https://github.com/siuyin/ch32v003fun/blob/871a7350aac339c28b52cc4c08f3cd86e4bc2701/ch32v003fun/ch32v003fun.h#L4856

qiyongshuang commented 1 year ago

I grabbed the MCO pin through the oscilloscope, and the system frequency shows 24M. I suspect your test program have question.

siuyin commented 1 year ago

R32_RCC_CFGR0 immediately after reset = 0x20. Causes HCLK=8MHz. According to documentation CFGR0 should be /1 but is actually /3.

RCC_CFGR-2023-05-26 18-10-32

mrx23dot commented 1 year ago

this also doesn't seem right rstrstrrrrr

siuyin commented 1 year ago

Indeed UART Enable should enable when set.

mrx23dot commented 1 year ago

It maybe meant that when disabled it waits for ongoing.

mrx23dot commented 1 year ago

This should be BRR

rstWolf

mrx23dot commented 1 year ago

USART_CTLR1_OVER8 ((uint16_t)0x8000) / USART Oversmapling 8-bits / is not documented

mrx23dot commented 1 year ago

LCKK says bit8 in doc, but ch32v00x_gpio.c says bit16

uint32_t tmp = 0x00010000;

qiyongshuang commented 10 months ago

Thank you very much, We will change it"uint32_t tmp = 0x00010000;"

mrx23dot commented 10 months ago

For some reason it asks me for password to open these in Foxit reader: CH32V003DS0.PDF CH32V003RM.PDF

could you please fix them?