Loading... ## 1. Homebrew 包管理工具安装 - 什么是homebrew - homebrew 是 Mac'Os系统里面的包管理工具,主要解决软件或者包下载时的各种依赖包。 - homebrew 下载安装 - ``` // 官方源 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" // 或者国内源 选择中科大的源 /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)" ``` - 安装完成后 终端中输入 <span style='color:orange'>brew -v</span> 如出现版本号代表安装成功 ## 2. 安装 SDCC [sdcc (Small Device C Compiler) ](http://sdcc.sourceforge.net/)是一个应用于单片机的一个交叉编译器,其官网上的解释是这样的 > `SDCC is a retargettable, optimizing Standard C (ANSI C89, ISO C99, ISO C11) compiler suite that targets the Intel MCS51 based microprocessors (8031, 8032, 8051, 8052, etc.), Maxim (formerly Dallas) DS80C390 variants, Freescale (formerly Motorola) HC08 based (hc08, s08), Zilog Z80 based MCUs (z80, z180, gbz80, Rabbit 2000/3000, Rabbit 3000A, TLCS-90), Padauk (pdk14, pdk15) and STMicroelectronics STM8. Work is in progress on supporting the Padauk (pdk13), Microchip PIC16 and PIC18 targets. It can be retargeted for other microprocessors.` ``` brew install sdcc sdcc -v ``` ## 3. 安装 python3 和 stcgal ``` brew install python3 // 安装stcgal 执行pip install stcgal即可安装 ``` ## 4. 安装ttl下载器的驱动 > 这边提供两种方式安装 - 1.官网下载安装 <span style='color:orange'>`CH340`</span> [下载地址](https://www.wch.cn/download/CH341SER_MAC_ZIP.html) - 2.brew 安装(推荐) ``` brew install --cask wch-ch34x-usb-serial-driver // 验证 连接单片机 // ll /dev/cu.wchusbserial140 比如我的.一般之后后三位不一样 ll /dev/cu.xxxxxxxxxxx ``` ## 5.编译main.c 并且转成 hex 格式 ``` sdcc main.c // ihx 转换 hex packihx main.ihx > main.hex // 下载到单片机中 stc89 为单片机协议 stcgal -P stc89 -p /dev/cu.wchusbserial140 main.hex ``` 如出现 <span style='color:green'>Waiting for MCU, please cycle power:</span>代表成功 此时按下 单片机的电源开关 重新启动单片机程序就会下载到单片机中 END 最后修改:2023 年 12 月 07 日 © 允许规范转载 打赏 赞赏作者 支付宝微信 赞 如果觉得我的文章对你有用,请随意赞赏 下一篇 上一篇 发表评论 取消回复 使用cookie技术保留您的个人信息以便您下次快速评论,继续评论表示您已同意该条款 评论 * 私密评论 名称 * 🎲 邮箱 * 地址 发表评论 提交中...