# About
FwLib_STC8 is a lite firmware library for STC8G/STC8H series MCU.
## Official Datasheets, User Manuals
* STC8A/8F: [Chinese](http://www.stcmcudata.com/STC8F-DATASHEET/STC8A-STC8F.pdf), [English](http://www.stcmcudata.com/STC8F-DATASHEET/STC8-english-20180320.pdf)
* STC8G: [Chinese](http://www.stcmcudata.com/STC8F-DATASHEET/STC8G.pdf), [English](https://www.stcmcudata.com/STC8F-DATASHEET/STC8G-EN.pdf)
* STC8H: [Chinese](http://www.stcmcudata.com/STC8F-DATASHEET/STC8H.pdf), [English](https://www.stcmcudata.com/STC8F-DATASHEET/STC8H-EN.pdf)
# Features
* Compatible with SDCC and Keil C51
* Optimized for constrained 8-bit MCU resources
* Readable code for on-chip resources operation
* Demos for quick start
# PlatformIO Quick Start
1. Clone this repository to local file system
```bash
# GitHub
git clone https://github.com/IOsetting/FwLib_STC8.git FwLib_STC8
# or Giteee (for Chinese users)
git clone https://gitee.com/iosetting/fw-lib_-stc8.git FwLib_STC8
```
2. Copy(or move) it to your PlatformIO project library, the file structure
```
├── include
├── lib
│ └── FwLib_STC8
│ ├── demo
│ ├── include
│ └── src
├── src
└── test
```
3. Add compile arguments in platformio.ini
```
build_flags =
-D__CONF_FOSC=36864000UL ;The osc/irc frequency you MCU will be running on
-D__CONF_MCU_MODEL=MCU_MODEL_STC8H3K32S2 ;change this to your MCU type
-D__CONF_CLKDIV=0x02 ;frequency trimming
-D__CONF_IRCBAND=0x03
-D__CONF_VRTRIM=0x19
-D__CONF_IRTRIM=0x28
-D__CONF_LIRTRIM=0x00
```
4. Include `fw_hal.h` in your code
```c
#include "fw_hal.h"
```
then it's ready to use.
# Keil C51 Quick Start
1. Clone this repository to local file system
```bash
# GitHub
git clone https://github.com/IOsetting/FwLib_STC8.git FwLib_STC8
# or Giteee (for Chinese users)
git clone https://gitee.com/iosetting/fw-lib_-stc8.git FwLib_STC8
```
2. Copy(or move) it to your Keil C51 project directory,
3. Add it to project through Project -> Manage -> Project Items,
4. Open project option dialog by clicking Project -> Options for Target ... , switch to C51 tab, and input following content in Preprocessor Symbols -> Define:
```
__CX51__, __CONF_MCU_MODEL=MCU_MODEL_STC8H3K32S2,__CONF_FOSC=36864000UL
```
The explanation of these arguments
```
__CX51__ This will tell the macros to switch to Keil C51 keywords
__CONF_MCU_MODEL, change this to your MCU type, please look into FwLib_STC8/include/fw_conf.h for all available types.
__CONF_FOSC The osc/irc frequency you MCU will be running on. It equals to the frequency this MCU will be trimmed to in STC-ISP.
```
5. Include `fw_hal.h` in your code
```c
#include "fw_hal.h"
```
then it's ready to use.
# Macros
Some macros were introduced for code compatibility with Keil C51 and SDCC.
The naming is from [sdcc compiler.h](https://sourceforge.net/p/sdcc/code/HEAD/tree/trunk/sdcc/device/include/mcs51/compiler.h). If you want your code to work with both compilers, you need to stick to these macros instead of the compiler specific keywords:
Here is a list of the macros:
| Macro | Keil C51 | SDCC |
| ----------- | ---------------- | ----------------- |
| __BIT | bit | __bit |
| __IDATA | idata | __idata |
| __PDATA | pdata | __pdata |
| __XDATA | xdata | __xdata |
| __CODE | code | __code |
| SBIT(name, addr, bit) | sbit name = addr^bit | __sbit __at(addr+bit) name |
| SFR(name, addr) | sfr name = addr | __sfr __at(addr) name |
| SFRX(addr) | (*(unsigned char volatile xdata *)(addr)) | (*(unsigned char volatile __xdata *)(addr)) |
| SFR16X(addr) | (*(unsigned int volatile xdata *)(addr)) | (*(unsigned int volatile __xdata *)(addr)) |
| INTERRUPT(name, vector) | void name (void) interrupt vector | void name (void) __interrupt (vector) |
| INTERRUPT_USING(name, vector, regnum) | void name (void) interrupt vector using regnum | void name (void) __interrupt (vector) __using (regnum) |
| NOP() | _nop_() | __asm NOP __endasm |
The definition of these macros can be found in include/fw_reg_base.h
# License
Copyright (c) 2021-present IOsetting <iosetting@outlook.com>
The FwLib_STC8 is licensed under the permissive Apache 2.0 license, you can use it in both commercial and personal projects with confidence.
没有合适的资源?快使用搜索试试~ 我知道了~
STC8G&STC8H封装库
共91个文件
c:49个
h:35个
md:4个
需积分: 5 6 下载量 112 浏览量
2023-10-19
22:22:21
上传
评论
收藏 175KB ZIP 举报
温馨提示
STC8G&STC8H封装库
资源推荐
资源详情
资源评论
收起资源包目录
STC8G&STC8H系列MCU封装库.zip (91个子文件)
FwLib_STC8-master
include
fw_iap.h 4KB
fw_cid_stc8h.h 4KB
fw_reg_stc8g.h 47KB
fw_mem.h 1KB
fw_exti.h 13KB
fw_util.h 994B
fw_rcc.h 3KB
fw_i2c.h 5KB
fw_adc.h 6KB
fw_reg_stc8a8k64d4.h 24KB
fw_conf.h 6KB
fw_reg_base.h 9KB
fw_uart.h 5KB
fw_gpio.h 7KB
fw_dma.h 5KB
fw_pwm.h 22KB
fw_cid_stc8g.h 2KB
fw_tim.h 6KB
fw_usb.h 8KB
fw_types.h 6KB
fw_pca.h 7KB
fw_sys.h 7KB
fw_cmp.h 4KB
fw_hal.h 1KB
fw_spi.h 3KB
fw_reg_stc8h.h 36KB
fw_wdt.h 2KB
fw_rtc.h 3KB
src
fw_adc.c 993B
fw_sys.c 2KB
fw_tim.c 4KB
fw_spi.c 914B
fw_uart.c 6KB
fw_usb.c 595B
fw_mem.c 1KB
fw_util.c 2KB
fw_i2c.c 2KB
README.cn.md 4KB
library.json 129B
LICENSE 11KB
demo
tim
timer2_timer_1t.c 1KB
timer0_print_cpuid.c 4KB
timer0_timer_1t.c 1KB
timer2_timer_12t.c 1KB
iap
eeprom_iap.c 3KB
usb
usb_hid.c 14KB
rtc
rtc_interrupt.c 2KB
pca
pca_pwm_8bit_2ch.c 2KB
pca_pwm_10bit_2ch.c 2KB
spi
adxl345
adxl345.c 2KB
adxl345.h 7KB
main.c 4KB
nrf24l01_audio
nrf24l01.h 7KB
nrf24l01.c 5KB
main.c 10KB
st7567
st7567_stc8h3k.c 4KB
st7567.h 10KB
st7567.c 17KB
nrf24l01
nrf24l01.h 7KB
nrf24l01.c 6KB
nrf24l01_stc8h1k.c 4KB
max7219
max7219_8x8led_4in1_stc8g1k08.c 6KB
max7219_8x8led_stc8g1k08.c 4KB
max7219_8x8led_4in1.c 6KB
max7219_8x8led.c 4KB
mem
mem_read_chipid.c 4KB
wdt
watchdog_reset.c 1KB
watchdog_clear_n_reset.c 2KB
adc
adc_interrupt_10bit.c 2KB
README.cn.md 3KB
adc_interrupt_2ch.c 3KB
adc_poll_10bit.c 2KB
README.md 3KB
adc_poll_8bit.c 2KB
uart
uart1_timer2_tx.c 988B
uart1_timer1_tx.c 988B
uart2_timer2_tx.c 980B
uart1_timer2_interrupt_tx_rx.c 1KB
i2c
ssd1306
ssd1306_stc8h3k.c 2KB
ssd1306.c 8KB
ssd1306.h 4KB
mpu6050
mpu6050.h 7KB
mpu6050.c 3KB
main.c 2KB
pwm
pwm_dac_voice
voice.h 56B
voice.c 129KB
main.c 3KB
pwm_2ch_complementary.c 3KB
pwm_2ch_timer2_interrupt.c 3KB
.gitignore 0B
README.md 4KB
共 91 条
- 1
资源评论
KavienW
- 粉丝: 3
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 蓝桥杯2024年第十五届省赛真题-前缀总分
- com.qihoo.appstore_300101305-1.apk
- tensorflow-gpu-2.7.1-cp37-cp37m-manylinux2010-x86-64.whl
- tensorflow-2.7.2-cp37-cp37m-manylinux2010-x86-64.whl
- tensorflow-2.7.1-cp39-cp39-manylinux2010-x86-64.whl
- 蓝桥杯2024年第十五届省赛真题-传送阵
- com.qihoo.appstore_300101305.apk
- linux之线程同步一.doc
- keil5配色方案10种
- python烟花代码.doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功