# CH554 software development kit for SDCC [![Build Status](https://travis-ci.org/Blinkinlabs/ch554_sdcc.svg?branch=master)](https://travis-ci.org/Blinkinlabs/ch554_sdcc)
![image](https://raw.githubusercontent.com/Blinkinlabs/ch554_sdcc/master/documentation/devboard.png)
This is a port of the CH554 SDK, from Keil C51 to SDCC.
The CH554 family of microcontrollers is notable because it has both an extremely low cost, USB device and host peripherals, and a preloaded USB bootloader.
# Getting Started
## Get the toolchain: Windows
You'll need a recent version of SDCC, as well as mingw for make, and likely also git-bash for the bash shell. Additionally, you'll need WCHISPTOOL to upload code to the chips.
* [git for windows](https://github.com/git-for-windows/git/releases/download/v2.15.1.windows.2/Git-2.15.1.2-64-bit.exe)
* [SDCC 3.6.0](https://sourceforge.net/projects/sdcc/files/latest/download?source=files)
* [mingw installer](https://downloads.sourceforge.net/project/mingw/Installer/mingw-get-setup.exe)
* [WCHISPTOOL](http://wch.cn/download/WCHISPTool_Setup_exe.html)
TODO: How to set up the enviroment to find these bits automatically
Once the tools are installed, add the following lines to the end of your .bashrc file:
# SDCC compiler tools
export PATH=$PATH:/c/Program\ Files/SDCC/bin
# Mingw tools (for Make)
export PATH=$PATH:/c/Qt/Qt5.10.0/Tools/mingw530_32/bin
alias make=mingw32-make.exe
TODO: Use standalone mingw tools instead of the ones from Qt
## Get the toolchain: Linux
For Debian-based systems, this should work:
sudo apt-install build-essential sdcc
We got a open-source implementation of this ISP Tool. You will get it from the following link:
* [LibreCH551](https://github.com/rgwan/librech551)
It works fine on CH551 and CH554.
The Makefile has "flash" operation, you have a convenient way to flash your chip. This program and operation also works on Windows (need Zadig to install driver) and Mac OS.
The usb-device-cdc-i2c example show you how to have a in-application firmware upgrade, it will make use of prelude flash operation..
## Get the toolchain: macOs
You'll need xcode (for make), as well as SDCC. ISP Tool will be same as Linux's.
## Build the examples
Then clone this repository, and build the examples:
git clone https://github.com/Blinkinlabs/ch554_sdcc.git
cd ch554_sdcc/examples
make
If everything is set up correctly, all of the examples should now be built.
Use the 'WCHISPTool' to flash an image onto the target device.
## Port a file from Keil C51 syntax to SDCC
The syntax for the two compilers are slightly incompatible. Notable issues from the SDK are:
* SFR and SBIT defines are different
* Absolute addressing format is different
* SDCC doesn't automatically track absolute-addressed variables
* SDCC can use standard types like 'uint8_t', the C51 examples used non-standard defines like 'UINT8'
* SDCC is little endian, while C51 appears to be big endian
This project includes a simplistic python script that can automatically translate some simple grammer changes. It can be used like this:
python tools/c51_to_sdcc.py [source] [destination]
With any luck it should do 90% of the translation work for you.
## Create a new example
Create a new directory in the examples folder, with the name of the new example:
cd examples/
mkdir fastblink
cd fastblink
Add a Makefile that referes to the master template makefile:
vi Makefile
With these contents:
TARGET = fastblink
C_FILES = \
main.c
include ../Makefile.include
Change the definition of target to match the new example name.
Next, add a barebones main file:
vi main.c
With these contents:
// Blink an LED connected to pin 1.7
#include <ch554.h>
#include <debug.h>
#define LED_PIN 7
SBIT(LED, 0x90, LED_PIN);
void main() {
// Configure pin 1.6 as GPIO output
P1_DIR_PU &= 0x0C;
P1_MOD_OC = P1_MOD_OC & ~(1<<LED_PIN);
P1_DIR_PU = P1_DIR_PU | (1<<LED_PIN);
while (1) {
mDelaymS(10);
LED = !LED;
}
}
And compile:
make
Oops! There is a problem:
$ make
sdcc -c -V -mmcs51 --model-small --xram-size 0x0400 --xram-loc 0x0000 --code-size 0x37FF -I../../include -DFREQ_SYS=12000000 main.c
+ /usr/bin/sdcpp -nostdinc -Wall -I../../include -DFREQ_SYS=12000000 -obj-ext=.rel -D__SDCC_MODEL_SMALL -D__SDCC_FLOAT_REENT -D__SDCC=3_5_0 -DSDCC=350 -D__SDCC_REVISION=9253 -D__SDCC_mcs51 -D__STDC_NO_COMPLEX__ -D__STDC_NO_THREADS__ -D__STDC_NO_ATOMICS__ -D__STDC_NO_VLA__ -isystem /usr/bin/../share/sdcc/include/mcs51 -isystem /usr/share/sdcc/include/mcs51 -isystem /usr/bin/../share/sdcc/include -isystem /usr/share/sdcc/include main.c
+ /usr/bin/sdas8051 -plosgffw main.rel main.asm
sdcc main.rel -V -mmcs51 --model-small --xram-size 0x0400 --xram-loc 0x0000 --code-size 0x37FF -I../../include -DFREQ_SYS=12000000 -o blink.ihx
+ /usr/bin/sdld -nf blink.lk
?ASlink-Warning-Undefined Global '_CfgFsys' referenced by module 'main'
?ASlink-Warning-Undefined Global '_mDelaymS' referenced by module 'main'
+ /usr/bin/sdld -nf blink.lk returned errorcode 512
../Makefile.include:38: recipe for target 'blink.ihx' failed
make: *** [blink.ihx] Error 1
Right, we forgot to add the debug.c source file to the Makefile. Update the Makefile so that it looks like this:
TARGET = fastblink
C_FILES = \
main.c \
../../include/debug.c
include ../Makefile.include
And re-run make. Everything should be fine:
$ make
sdcc -c -V -mmcs51 --model-small --xram-size 0x0400 --xram-loc 0x0000 --code-size 0x37FF -I../../include -DFREQ_SYS=12000000 ../../include/debug.c
+ /usr/bin/sdcpp -nostdinc -Wall -I../../include -DFREQ_SYS=12000000 -obj-ext=.rel -D__SDCC_MODEL_SMALL -D__SDCC_FLOAT_REENT -D__SDCC=3_5_0 -DSDCC=350 -D__SDCC_REVISION=9253 -D__SDCC_mcs51 -D__STDC_NO_COMPLEX__ -D__STDC_NO_THREADS__ -D__STDC_NO_ATOMICS__ -D__STDC_NO_VLA__ -isystem /usr/bin/../share/sdcc/include/mcs51 -isystem /usr/share/sdcc/include/mcs51 -isystem /usr/bin/../share/sdcc/include -isystem /usr/share/sdcc/include ../../include/debug.c
../../include/debug.c:225: warning 158: overflow in implicit constant conversion
+ /usr/bin/sdas8051 -plosgffw debug.rel debug.asm
sdcc main.rel debug.rel -V -mmcs51 --model-small --xram-size 0x0400 --xram-loc 0x0000 --code-size 0x37FF -I../../include -DFREQ_SYS=12000000 -o fastblink.ihx
+ /usr/bin/sdld -nf fastblink.lk
packihx fastblink.ihx > fastblink.hex
packihx: read 31 lines, wrote 48: OK.
The .hex file can now be loaded onto the target using WCHISPTOOL.
## Build configuration variables
The build configuration is specified in the master Makefile.include file, however some variables can be overridden by the local Makefile:
| Makefile variable | Description |
| --- | --- |
| TARGET | Example name, used to name the .hex file |
| C_FILES | List of c files to include in the example build |
| FREQ_SYS | System clock frequency. Default is 12000000 (12MHz). See 'include/debug.c' for a list of accepted values |
| XRAM_SIZE | Size of the non-reserved XRAM. Update to reserve a portion of the XRAM for absolute variables, such as for the USB DMA pointer |
| XRAM_LOC | Starting position of the non-reserved XRAM. Update to reserve a portion of the XRAM for absolute variables, such as for the USB DMA pointer |
| STDIO_UART | Set to '0' to use UART0 for STDIO, or '1' to use UART1 for STDIO (not finished) |
# Status
Here is a list of the different peripheral drivers and examples that need to be ported
| Peripheral | Description | Status |
| --- | --- | --- |
| ADC | Analog-to-digital converter | not started |
| DataFlash | DataFlash (EEPROM) peripheral | not started |
| GPIO | I/O peripheral example | not started |
| UART0/stdlib | stdio example using UART0 | in progress |
| UART1/stdlib | stdio example using UART1 | in progress |
| Watchdog | Watchdog timer configuration | not started |
| IAP | Jump from user program to the bootloader | complete |
| PWM | Pulse Width modulation peripheral | com
没有合适的资源?快使用搜索试试~ 我知道了~
CH552 windows 开发工具
共97个文件
c:24个
h:15个
makefile:15个
需积分: 8 0 下载量 15 浏览量
2023-01-03
08:06:54
上传
评论
收藏 31.28MB RAR 举报
温馨提示
CH552 开发工具,使用方法见博客,https://blog.csdn.net/jjinl/article/details/122462103?spm=1001.2014.3001.5502
资源推荐
资源详情
资源评论
收起资源包目录
CH552_tools.rar (97个子文件)
CH552
操作说明_无声.mp4 21.42MB
sdcc-3.5.0-x64-setup.exe 5.66MB
WCHISPTool_Setup.exe 1.67MB
make.exe 316KB
ch55x_jtag-master
src
debug.sym 50KB
main.asm 103KB
debug.rel 11KB
usb_jtag.lnk 254B
usb_jtag.ihx 15KB
Makefile 447B
main.rst 291KB
usb_jtag.hex 17KB
main.lst 287KB
debug.lst 64KB
usb_jtag.lk 258B
usb_jtag.bin 6KB
usb_jtag.map 36KB
usb_jtag.mem 1KB
debug.asm 27KB
main.c 51KB
debug.rst 64KB
main.rel 60KB
main.sym 57KB
.gitmodules 94B
.gitignore 27B
ch554_sdcc
include
touchkey.c 5KB
spi.h 3KB
pwm.h 2KB
debug.h 1KB
ch554.h 51KB
ch554_datatypes.h 3KB
spi.c 6KB
bootloader.h 86B
debug.c 11KB
touchkey.h 3KB
ch554_usb.h 10KB
tools
c51_to_sdcc.py 3KB
documentation
CH554 manual english.pdf 931KB
CH554 manual 1E (chinese).pdf 618KB
CH554 manual english.odt 1.2MB
USB MCU CH554 evaluation board instructions english.pdf 397KB
USB MCU CH554 evaluation board instructions english.odt 397KB
devboard.png 104KB
CONTRIBUTING.md 5KB
examples
pwm_interrupt
Makefile 87B
main.c 720B
touchkey
Makefile 135B
main.c 3KB
iap
Makefile 102B
main.c 574B
ws2812
bitbang.c 4KB
Makefile 171B
bitbang.h 100B
main.c 979B
blink
Makefile 104B
main.c 365B
Makefile 147B
usb_device_cdc
Makefile 385B
main.c 31KB
usb_spi_flash
flash.py 2KB
spi_flash.h 2KB
Makefile 504B
usb_spi_flash.h 245B
main.c 31KB
spi_flash.c 4KB
usb_spi_flash.c 4KB
Makefile.include 2KB
usb_device_cdc_i2c
Makefile 102B
README.txt 1KB
commandline
Makefile 84B
si5351.c 18KB
si5351.h 9KB
.gitignore 7B
firmware
i2c.c 1KB
Makefile 496B
i2c.h 583B
main.c 24KB
usb_device_midi
Makefile 415B
main.c 20KB
pwm
Makefile 77B
main.c 460B
README.md 9KB
README.md 914B
test.bat 3B
ch552_ex1
usb.c 8KB
usbjtag.h 3KB
usbjtag.py 11KB
misc.c 4KB
Makefile 545B
LICENSE 1KB
usbjtag.hex 12KB
ch552.h 6KB
pmu.c 3KB
spi.c 6KB
usbjtag.bin 5KB
README.md 2KB
usbjtag.c 5KB
共 97 条
- 1
资源评论
jjinl
- 粉丝: 42
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功