Skip to content

Commit 030da48

Browse files
authored
Board definition for CH32X033F8P6 TSSOP20 #171
At the current stage it works for me. Have fun! Info below is also in the readme of the board definition directory. +------v------+ MISO/A6 D6~ 1-+PA6 PA5+-20 D5 SCK/A5 MOSI/A8/TX4 D7 2-+PA7=PB0 PA4+-19 D4~ CS/A4 A9/RX4 D8 3-+PB1 PC19+-18 D17 SWCLK /RST D9 4-+PB7 PA3+-17 D3~ RX2/A3* USBDM D10 5-+PC16=PC11 PA2+-16 D2~ TX2/A2 USBDP D11 6-+PC17=PC10 PA1+-15 D1~ A1 GND 7-+VSS PA0+-14 D0~ A0 SWDIO D16 8-+PC18 PC3+-13 D15~ A13 VCC 9-+VDD PA10+-12 D14 SCL/TX1 D12 10-+PA9 PA11+-11 D13 SDA/RX1 +-------------+ *A3, VREF and hardware I2C don't work on CH32X033F8P6 0-series (lot number with the penultimate bit 5 being 0). Tested features digitalWrite()/digitalRead() - can use Arduino pin numbers or PAx notation. analogWrite() - 12-bit resolution, pins marked with ~ in pinout above. analogRead() - very stable 12-bit resolution, but issues with A3/A0/PADC_VREF Serial.print() - Tested 115200 bps on Serial2 (PA2/PA3) and Serial1 (PA10/PA11), as set in variant_CH32X033F8P6.h EEPROM library - may need improvement (updated to support 122 bytes). Pin PB7 (Arduino pin 9) can be configured as hardware reset /RST using WCH Link Utility. (See issue Hardware reset pin doesn't work on CH32X033 or CH32X035 #123) Known issues/limitations Pins PA7/PB0, PC16/PC11 and PC17/PC10 cannot be used for output. Any signal on A0 seems to show on other ADC pins when disconnected. A3, PADC_VREF and I2C don't work on CH32X033F8P6 0-series (lot number with the penultimate bit 5 being 0). To counter missing I2C the Software_I2C library by Seeed Studio is a good alternative, although it needs some changes to improve compatibility in I2C scanning. openwch/arduino_core_ch32#171
1 parent 570ed27 commit 030da48

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

libraries/EEPROM/README.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ The EEPROM library provides an easy to use interface to interact with the intern
66
This CH32 version of the library provides a familiar API to emulated EEPROM using the Option bytes area in flash memory.
77

88
Ported to CH32 by Maxint R&D, based on multiple sources:
9-
- Code from the Option Data example of CH32V003fun by @CNLOHR.
9+
- Code from the Option Data example of CH32V003fun by @CNLOHR and various WCH EVT Flash examples.
1010
- Arduino original copyright (c) 2006 David A. Mellis. All right reserved. New version by Christopher Andrews 2015.
1111
- ESP8266 version copyright (c) 2014 Ivan Grokhotkov. All rights reserved.
1212

1313
## Table of contents
1414
- [CH32V003 emulated EEPROM](#ch32v003-emulated-eeprom)
15+
- - [CH32 boards with larger emulated EEPROM](#ch32-boards-with-larger-emulated-eeprom)
1516
- [How to use this library](#how-to-use-this-library)
1617
- [Library functions](#library-functions)
1718
- [Features & limitations](#features--limitations)
@@ -41,6 +42,17 @@ Layout for uint8_t _data[26]: { ob[4], ob[6], ob[16...62] ].
4142

4243
The first release of this library was made for the CH32V003 and only uses the user select word storage area.
4344
It was tested using Arduino IDE 2.3.2 and OpenWCH core 1.0.4.
45+
46+
### CH32 boards with larger emulated EEPROM
47+
Depending on the board, the size of the user-defined information storage area can be different, allowing for a larger emulated EEPROM.
48+
For all CH32 chips the starting address is 0x1FFFF800. The first 16 bytes is for configuration, including 4 bytes for data0/data1.
49+
The remainder can be used for EEPROM values and their inverse. The method to write these bytes can be different per chip.
50+
- 64B => 2+(64-16)/2=2+24=26B: CH32V003
51+
- 128B => 2+(128-16)/2=2+56=58B: CH32V103, CH32V20x, CH32V30x/31x
52+
- 256B => 2+(256-16)/2=2+120=122B: CH32V002/V004/V006/V007, CH32X033/X035
53+
54+
Currently tested to work: CH32V003/CH32V002/CH32V006/CH32X033.
55+
(CH32VM00X required updated ch32v00x_flash.c from latest EVT code)
4456
Future releases of this library may support other CH32 processors and allow for larger memory sizes.
4557

4658
### **How to use this library**
@@ -150,9 +162,11 @@ The method returns a `uint32_t` value, containing the data0 and data1 bytes and
150162
---
151163

152164
## Features & limitations
153-
- The first release of this library was made only for the CH32V003 and has been tested on that MCU only. Other members of the CH32 may behave incorrectly or not work at all.
154-
- This EEPROM implementation for the CH32V003 has only 26 bytes available. When addressing more, things are likely to go wrong. A future release may allow using more pages from the flash memory.
165+
- The first release of this library was made for the CH32V003, offering 26 bytes of emulated EEPROM. It was tested on CH32V003 and CH32X033.
166+
. The next release offered 122 bytes of emulated EEPROM on CH32X035/X033 and CH32VM00X (V002/V004/V006/V008). It passed tests on V002, V006 and X033.
167+
- Other members of the CH32 may behave incorrectly or not work at all. A test on V103 showed issues writing more than the first two bytes.
155168
- Most CH32 EEPROM methods are the same as their equivalent on regular Arduino's. BEWARE: The begin() and end() methods are like their counterparts for ESP8266/ESP32, but are very different from the begin() and end() methods of EEPROM v2.0 by Christopher Andrews, who introduced them to support C++ iterators. This library follows the begin() convention introduced by the Serial and Wire classes, i.e. to initialize the object.
156169

157170
## Disclaimer
158171
- All code on this GitHub account, including this library is provided to you on an as-is basis without guarantees and with all liability dismissed. It may be used at your own risk. Unfortunately I have no means to provide support.
172+

0 commit comments

Comments
 (0)