1. 指定阿里云镜像, 安装REQUIREMENTS.TXT中的所有
pip install -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com -r requirements.txt
2. 指定阿里云镜像, 安装FLASK
pip install -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com flask
zsh: command not found 的部分解决方案
Golang的 解决方案方案,
# GOROOT
export GOROOT=/usr/local/go
export PATH=$PATH:/usr/local/go/bin
#GOPATH
export GOPATH=$HOME/go_place
export PATH=$PATH:$GOPATH/bin
# GOPROXY
export GO111MODULE=on
export GOPROXY=https://goproxy.cn,direct
#GOBIN
export GOBIN=$GOPATH/bin
# MySQL 添加MySQL到环境变量 Mac下
# export PATH=$PATH:/usr/local/mysql/bin
# 配置cuda
# 在 .bashrc 最后添加以下内容
export PATH=/usr/local/cuda-11.7/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-11.7/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
# 此处的11.8应该与你的安装的cuda一致
此时的系统go env 查看当前Golang的环境变量
(base) ➜ ~ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN="/home/banana/go_place/bin"
GOCACHE="/home/banana/.cache/go-build"
GOENV="/home/banana/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/banana/go_place/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/banana/go_place"
GOPRIVATE=""
GOPROXY="https://goproxy.cn,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.20.5"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build403313969=/tmp/go-build -gno-record-gcc-switches"
Golang的安装
复制Golang的linux下载链接
# 方法一
wget -c https://studygolang.com/dl/golang/go1.19.linux-amd64.tar.gz
tar -zxvf go1.19.linux-amd64.tar.gz
sudo mv go /usr/local
# 方法二
# step 1
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.19.linux-amd64.tar.gz
# 将一下内容 写入 $HOME/.profile or /etc/profile
export PATH=$PATH:/usr/local/go/bin
# 然后按 ESC :wq 确认后
source $HOME/.profile
#or
source /etc/profile
go env # 确认你的安装
Golang在zsh下的配置
cd ~
vim .zshrc
# 将下面的内容添加到.zshrc 中
#
# GOROOT
export PATH=$PATH:/usr/local/go/bin
#GOPATH
export GOPATH=$HOME/go_place
export PATH=$PATH:$GOPATH/bin
# ESC :wq保存后
source .zshrc # 就可以了
这里的基本思路就是以前golang的环境配置在bash下的profile,这里是添加到zsh的环境配置
anaconda的环境配置
anaconda/bin/conda init zsh
这里基本思路就是用conda自己自动初始化zsh
最后写一些oh my zsh的配置
sudo apt install zsh
ubuntu默认shell是bash,apt安装zsh之后直接用oh my zsh的命令就可以自动切换到oh my zsh
# 安装 在本地克隆后获取安装脚本。
# 清华 镜像源 https://mirrors.tuna.tsinghua.edu.cn/help/ohmyzsh.git/
git clone https://mirrors.tuna.tsinghua.edu.cn/git/ohmyzsh.git
cd ohmyzsh/tools
REMOTE=https://mirrors.tuna.tsinghua.edu.cn/git/ohmyzsh.git sh install.sh
# 切换已有 ohmyzsh 至镜像源
git -C $ZSH remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/ohmyzsh.git
git -C $ZSH pull
补充内容
Brew 安装 Homebrew国内源
知乎文章地址:https://zhuanlan.zhihu.com/p/111014448
苹果电脑标准安装脚本:(推荐 优点全面 缺点慢一点)
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
苹果电脑极速安装脚本:(优点安装速度快 缺点update功能需要命令修复 )
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)" speed
Linux 标准安装脚本:
rm Homebrew.sh ; wget https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh ; bash Homebrew.sh
苹果电脑卸载脚本:
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/HomebrewUninstall.sh)"
Linux卸载脚本:
rm HomebrewUninstall.sh ; wget https://gitee.com/cunkai/HomebrewCN/raw/master/HomebrewUninstall.sh ; bash HomebrewUninstall.sh
---Brew介绍
macOS 和 Linux 缺失软件包的管理器
---Homebrew 能干什么?
使用 Homebrew 安装 Mac(或Linux)没有预装但你需要的东西。
--Homebrew自身如何使用
知道软件包具体名称,直接 brew install 软件包名 只知道一小部分名称,用 brew search 小部分名称 查询即可 例如brew search chrome就会把带chrome的软件包全部列出
brew 安装完成检查
(base) ➜ ~ brew -v
Homebrew 4.1.25-89-g4793677
Homebrew/homebrew-core (git revision 3e153b54ec7; last commit 2023-12-17)
Homebrew/homebrew-cask (git revision 6b34c78320; last commit 2023-12-17)
(base) ➜ ~ brew search tree
==> Formulae
as-tree datree erdtree pstree tree ✔ treecc treefrog
cherrytree dutree pipdeptree python-anytree tree-sitter treefmt tre
==> Casks
figtree sourcetree treesheets trex
(base) ➜ ~ brew install tree
Warning: No remote 'origin' in /opt/homebrew/Library/Taps/homebrew/homebrew-services, skipping update!
Running `brew update --auto-update`...
Installing from the API is now the default behaviour!
You can save space and time by running:
brew untap homebrew/core
brew untap homebrew/cask
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
You have 1 outdated formula installed.
tree 2.1.1 is already installed but outdated (so it will be upgraded).
==> Fetching tree
==> Downloading https://mirrors.bfsu.edu.cn/homebrew-bottles/tree-2.1.1_1.arm64_monterey.bottle.tar.gz
################################################################################################################# 100.0%
==> Upgrading tree
2.1.1 -> 2.1.1_1
==> Pouring tree-2.1.1_1.arm64_monterey.bottle.tar.gz
🍺 /opt/homebrew/Cellar/tree/2.1.1_1: 8 files, 177.1KB
==> Running `brew cleanup tree`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
Removing: /opt/homebrew/Cellar/tree/2.1.1... (8 files, 177.2KB)
(base) ➜ ~ neofetch
'c. banana@MacBook-Pro.local
,xNMM. -----------------------------
.OMMMMo OS: macOS 12.7.2 21G1974 arm64
OMMM0, Host: MacBookPro18,1
.;loddo:' loolloddol;. Kernel: 21.6.0
cKMMMMMMMMMMNWMMMMMMMMMM0: Uptime: 7 days, 3 hours, 12 mins
.KMMMMMMMMMMMMMMMMMMMMMMMWd. Packages: 17 (brew)
XMMMMMMMMMMMMMMMMMMMMMMMX. Shell: zsh 5.8.1
;MMMMMMMMMMMMMMMMMMMMMMMM: Resolution: 1728x1117
:MMMMMMMMMMMMMMMMMMMMMMMM: DE: Aqua
.MMMMMMMMMMMMMMMMMMMMMMMMX. WM: Quartz Compositor
kMMMMMMMMMMMMMMMMMMMMMMMMWd. WM Theme: Blue (Light)
.XMMMMMMMMMMMMMMMMMMMMMMMMMMk Terminal: iTerm2
.XMMMMMMMMMMMMMMMMMMMMMMMMK. Terminal Font: Monaco 14
kMMMMMMMMMMMMMMMMMMMMMMd CPU: Apple M1 Pro
;KMMMMMMMWXXWMMMMMMMk. GPU: Apple M1 Pro
.cooc,. .,coo:. Memory: 3951MiB / 32768MiB
(base) ➜ ~ screenfetch
zsh: command not found: screenfetch
(base) ➜ ~ brew install screenfetch
Warning: No remote 'origin' in /opt/homebrew/Library/Taps/homebrew/homebrew-services, skipping update!
==> Fetching screenfetch
==> Downloading https://mirrors.bfsu.edu.cn/homebrew-bottles/screenfetch-3.9.1.arm64_monterey.bottle.tar.gz
################################################################################################################# 100.0%
==> Pouring screenfetch-3.9.1.arm64_monterey.bottle.tar.gz
🍺 /opt/homebrew/Cellar/screenfetch/3.9.1: 8 files, 302.2KB
==> Running `brew cleanup screenfetch`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
(base) ➜ ~ screenfetch
awk: can't open file /proc/cpuinfo
source line number 1
grep: /proc/cpuinfo: No such file or directory
awk: can't open file /proc/cpuinfo
source line number 1
awk: can't open file /proc/cpuinfo
source line number 1
grep: /proc/cpuinfo: No such file or directory
awk: can't open file /proc/cpuinfo
source line number 1
/opt/homebrew/bin/screenfetch: line 1801: free: command not found
/opt/homebrew/bin/screenfetch: line 1803: / 1024 / 1024: syntax error: operand expected (error token is "/ 1024 / 1024")
banana@MacBook-Pro.local
OS: unknown
UUU UUU NNN NNN IIIII XXX XXXX Kernel: arm64 Darwin 21.6.0
UUU UUU NNNN NNN III XX xXX Uptime:
UUU UUU NNNNN NNN III XX xXX Packages: Unknown
UUU UUU NNN NN NNN III XXXX Shell: 5413
UUU UUU NNN NN NNN III xXX Disk: / ()
UUU UUU NNN NN NNN III xXXXX CPU: Unknown
UUU UUU NNN NNNNN III xXX XX RAM:
UUUuuuUUU NNN NNNN III xXX XX
UUUUU NNN NNN IIIII xXXx xXXx
(base) ➜ ~
Mac版下实现51单片机进行开发的环境搭建
brew环境下安装 sdcc
brew install sdcc
sdcc -version
(base) ➜ ~ sdcc -version
at 1: warning 152: Only one short option can be specified at a time. Rest of -version ignored.
SDCC : mcs51/z80/z180/r2k/r2ka/r3ka/sm83/tlcs90/ez80_z80/z80n/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8/pdk13/pdk14/pdk15/mos6502 TD- 4.3.0 #14184 (Mac OS X ppc)
published under GNU General Public License (GPL)
安装CH341驱动
CH341SER_MAC.ZIP - 南京沁恒微电子股份有限公司
开发板上默认已经集成了usb转串口模块,它上面使用的CH340芯片。但是在CH340官网上面没有找到mac系统的驱动,只找到了CH341版本的mac系统驱动,根据官方文档说明,这个驱动也兼容CH340芯片,所以安装CH341版本的驱动就可以了。
记得先给安装器隐私权限!!!
然后将下载好的 zip文件解压打开双击运行目录里面的ch34xInstall.pkg,根据提示一直点击下一步就可以了,最后按照提示重启电脑就可以了。
接着我们就要确定驱动是否安装成功
将单片机连接到电脑上然后打开终端命令行窗口后执行:
ls /dev/tty.wchusbser*
烧录程序stcgal的安装
需要python环境,可以是anaconda或者是brew下安装
(base) ➜ ~ pip install stcgal
(base) ➜ ~ stcgal -version
(base) ➜ ~ stcgal -version
usage: stcgal [-h] [-e] [-a] [-A {dtr,rts}] [-r RESETCMD]
[-P {stc89,stc89a,stc12a,stc12b,stc12,stc15a,stc15,stc8,stc8d,stc8g,usb15,auto}] [-p PORT] [-b BAUD]
[-l HANDSHAKE] [-o OPTION] [-t TRIM] [-D] [-V]
[code_image] [eeprom_image]
stcgal: error: unrecognized arguments: -version
测试单片机
写一个C程序测试 main.c
!!!注意是8052.h 头文件
#include <8052.h> // 引用头文件
#define ADDR0 P2_0
#define ADDR1 P2_1
#define ADDR2 P2_2
#define ADDR3 P2_3
#define ENLED P2_4
//========= 延时 ============
void delay_ms(unsigned int s){
unsigned int x;
for(s;s>0;s--){
x = 98;
while(x--);
}
}
//================ 主函数 ===================
void main(){
unsigned char i;
ENLED = 0;
ADDR3 = 1;
ADDR2 = 1;
ADDR1 = 1;
ADDR0 = 0;
while(1){ //主循环
P2 = 0xff;
delay_ms(150);
for(i = 0;i<8;i++){
P2 = P2 <<1;
delay_ms(150);
}
P2 = 0xff;
delay_ms(150);
for(i = 0;i<8;i++){
P2 = P2 >>1;
delay_ms(150);
}
}
}
编译
(base) ➜ sdcc main.c
(base) ➜ ~ ls -lha main*
-rw-r--r-- 1 tanhu staff 9.7K 12 25 07:12 main.asm
-rw-r--r-- 1 tanhu staff 782B 12 25 07:12 main.c
-rw-r--r-- 1 tanhu staff 606B 12 25 07:12 main.ihx
-rw-r--r-- 1 tanhu staff 273B 12 25 07:12 main.lk
-rw-r--r-- 1 tanhu staff 28K 12 25 07:12 main.lst
-rw-r--r-- 1 tanhu staff 18K 12 25 07:12 main.map
-rw-r--r-- 1 tanhu staff 1.1K 12 25 07:12 main.mem
-rw-r--r-- 1 tanhu staff 4.5K 12 25 07:12 main.rel
-rw-r--r-- 1 tanhu staff 28K 12 25 07:12 main.rst
-rw-r--r-- 1 tanhu staff 40K 12 25 07:12 main.sym
写入单片机
(base) ➜ ~ stcgal -P stc89 -p /dev/tty.wchusbserial130 main.ihx
Waiting for MCU, please cycle power: done
Target model:
Name: STC89C516RD+/LE516RD+
Magic: F110
Code flash: 62.0 KB
EEPROM flash: 0.0 KB
Target frequency: 11.010 MHz
Target BSL version: 4.3C
Target options:
cpu_6t_enabled=False
bsl_pindetect_enabled=False
eeprom_erase_enabled=False
clock_gain=high
ale_enabled=True
xram_enabled=True
watchdog_por_enabled=False
Loading flash: 213 bytes (Intel HEX)
Switching to 115200 baud: checking setting testing done
Erasing 2 blocks: done
Writing flash: 640 Bytes [00:00, 4297.72 Bytes/s]
Setting options: done
Disconnected!
上面的参数
-P 表示使用的是stc89型号,
-p /dev/tty.wchusbserialfd120 表示usb串口设备号 ,
a.ihx 是刚刚编译好的程序!
a.ihx是文件名,其他的复制粘贴就行
输入
(base) ➜ ~ ls /dev/tty.wchusbser*
/dev/tty.wchusbserial130
就可以看到串口号
出现Waiting for MCU, please cycle power:
开关一下电源键,就OK啦!
(base) ➜ ~ ls /dev/tty.wchusbser*
/dev/tty.wchusbserial130
(base) ➜ ~ stcgal -P stc89 -p /dev/tty.wchusbserial130 main.ihx
Waiting for MCU, please cycle power: done
# 先出现上一行代码 需要你 重启单片机 即先关机在开机 才能刷程序进单片机
# 以下是程序正常刷入单片机的流程
Target model:
Name: STC89C516RD+/LE516RD+
Magic: F110
Code flash: 62.0 KB
EEPROM flash: 0.0 KB
Target frequency: 11.010 MHz
Target BSL version: 4.3C
Target options:
cpu_6t_enabled=False
bsl_pindetect_enabled=False
eeprom_erase_enabled=False
clock_gain=high
ale_enabled=True
xram_enabled=True
watchdog_por_enabled=False
Loading flash: 213 bytes (Intel HEX)
Switching to 115200 baud: checking setting testing done
Erasing 2 blocks: done
Writing flash: 640 Bytes [00:00, 4297.72 Bytes/s]
Setting options: done
Disconnected!

重点
使用sdcc编译单片机程序,跟windows下面keil的c代码是有一些差别的,列表如下:
可以看到,这个差别是非常小的。一定要注意不要用错了头文件的引用,不然会报错,要多多注意一下,提高编程的效率。其它的内容,碰到了就注意用对应的语法。
好了,这就是自己搭建环境过程的所有记录啦!!当然,在这过程我也是有在网上搜索大量的资料阅读并了解喔。哪里不懂搜哪里喔!!!
8051头文件 8051.h
/*-------------------------------------------------------------------------
8051.h: Intel 8051 处理器的寄存器声明
版权所有 (C) 2000,Bela Torok / bela.torok@kssg.ch
本库是自由软件;您可以重新发布或修改它
遵循由自由软件基金会发布的 GNU 通用公共许可证;
要么版本 2,或者(如果您选择的话)任何以后的版本。
本库被分发,希望它会有用,
但没有任何担保;甚至没有对适销性或特定用途的暗示担保。
详见 GNU 通用公共许可证获取更多详情。
您应该已经收到一份 GNU 通用公共许可证的副本
与本库一同;请参阅 COPYING 文件。如果没有,请写信给
自由软件基金会,地址:51 Franklin Street,第五层,波士顿,
MA 02110-1301,美国。
作为一个特殊的例外,如果您将此库与其他文件链接,
其中一些是使用 SDCC 编译的,以生成可执行文件,
本库本身不会导致生成的可执行文件受 GNU 通用公共许可证的覆盖。
但是,此例外并不使得其他原因导致的可执行文件不受 GNU 通用公共许可证的影响。
-------------------------------------------------------------------------*/
#ifndef REG8051_H
#define REG8051_H
/* BYTE 寄存器 */
__sfr __at (0x80) P0 ;
__sfr __at (0x81) SP ;
__sfr __at (0x82) DPL ;
__sfr __at (0x83) DPH ;
__sfr __at (0x87) PCON ;
__sfr __at (0x88) TCON ;
__sfr __at (0x89) TMOD ;
__sfr __at (0x8A) TL0 ;
__sfr __at (0x8B) TL1 ;
__sfr __at (0x8C) TH0 ;
__sfr __at (0x8D) TH1 ;
__sfr __at (0x90) P1 ;
__sfr __at (0x98) SCON ;
__sfr __at (0x99) SBUF ;
__sfr __at (0xA0) P2 ;
__sfr __at (0xA8) IE ;
__sfr __at (0xB0) P3 ;
__sfr __at (0xB8) IP ;
__sfr __at (0xD0) PSW ;
__sfr __at (0xE0) ACC ;
__sfr __at (0xF0) B ;
/* BIT 寄存器 */
/* P0 */
__sbit __at (0x80) P0_0 ;
__sbit __at (0x81) P0_1 ;
__sbit __at (0x82) P0_2 ;
__sbit __at (0x83) P0_3 ;
__sbit __at (0x84) P0_4 ;
__sbit __at (0x85) P0_5 ;
__sbit __at (0x86) P0_6 ;
__sbit __at (0x87) P0_7 ;
/* TCON */
__sbit __at (0x88) IT0 ;
__sbit __at (0x89) IE0 ;
__sbit __at (0x8A) IT1 ;
__sbit __at (0x8B) IE1 ;
__sbit __at (0x8C) TR0 ;
__sbit __at (0x8D) TF0 ;
__sbit __at (0x8E) TR1 ;
__sbit __at (0x8F) TF1 ;
/* P1 */
__sbit __at (0x90) P1_0 ;
__sbit __at (0x91) P1_1 ;
__sbit __at (0x92) P1_2 ;
__sbit __at (0x93) P1_3 ;
__sbit __at (0x94) P1_4 ;
__sbit __at (0x95) P1_5 ;
__sbit __at (0x96) P1_6 ;
__sbit __at (0x97) P1_7 ;
/* SCON */
__sbit __at (0x98) RI ;
__sbit __at (0x99) TI ;
__sbit __at (0x9A) RB8 ;
__sbit __at (0x9B) TB8 ;
__sbit __at (0x9C) REN ;
__sbit __at (0x9D) SM2 ;
__sbit __at (0x9E) SM1 ;
__sbit __at (0x9F) SM0 ;
/* P2 */
__sbit __at (0xA0) P2_0 ;
__sbit __at (0xA1) P2_1 ;
__sbit __at (0xA2) P2_2 ;
__sbit __at (0xA3) P2_3 ;
__sbit __at (0xA4) P2_4 ;
__sbit __at (0xA5) P2_5 ;
__sbit __at (0xA6) P2_6 ;
__sbit __at (0xA7) P2_7 ;
/* IE */
__sbit __at (0xA8) EX0 ;
__sbit __at (0xA9) ET0 ;
__sbit __at (0xAA) EX1 ;
__sbit __at (0xAB) ET1 ;
__sbit __at (0xAC) ES ;
__sbit __at (0xAF) EA ;
/* P3 */
__sbit __at (0xB0) P3_0 ;
__sbit __at (0xB1) P3_1 ;
__sbit __at (0xB2) P3_2 ;
__sbit __at (0xB3) P3_3 ;
__sbit __at (0xB4) P3_4 ;
__sbit __at (0xB5) P3_5 ;
__sbit __at (0xB6)
8052头文件 8052.h
/*-------------------------------------------------------------------------
8052.h: Intel 8052 处理器的寄存器声明
版权所有 (C) 2000,Bela Torok / bela.torok@kssg.ch
本库是自由软件;您可以重新发布或修改它
遵循由自由软件基金会发布的 GNU 通用公共许可证;
要么版本 2,或者(如果您选择的话)任何以后的版本。
本库被分发,希望它会有用,
但没有任何担保;甚至没有对适销性或特定用途的暗示担保。
详见 GNU 通用公共许可证获取更多详情。
您应该已经收到一份 GNU 通用公共许可证的副本
与本库一同;请参阅 COPYING 文件。如果没有,请写信给
自由软件基金会,地址:51 Franklin Street,第五层,波士顿,
MA 02110-1301,美国。
作为一个特殊的例外,如果您将此库与其他文件链接,
其中一些是使用 SDCC 编译的,以生成可执行文件,
本库本身不会导致生成的可执行文件受 GNU 通用公共许可证的覆盖。
但是,此例外并不使得其他原因导致的可执行文件不受 GNU 通用公共许可证的影响。
-------------------------------------------------------------------------*/
#ifndef REG8052_H
#define REG8052_H
#include <8051.h> /* 载入 8051 核心的定义 */
#ifdef REG8051_H
#undef REG8051_H
#endif
/* 仅定义 8052 特定的寄存器 */
/* T2CON 寄存器 */
__sfr __at (0xC8) T2CON ;
/* RCAP2 L & H 寄存器 */
__sfr __at (0xCA) RCAP2L ;
__sfr __at (0xCB) RCAP2H ;
__sfr __at (0xCC) TL2 ;
__sfr __at (0xCD) TH2 ;
/* IE 寄存器 */
__sbit __at (0xAD) ET2 ; /* 使能定时器2中断 */
/* IP 寄存器 */
__sbit __at (0xBD) PT2 ; /* T2 中断优先级位 */
/* T2CON 寄存器位定义 */
__sbit __at (0xC8) T2CON_0 ;
__sbit __at (0xC9) T2CON_1 ;
__sbit __at (0xCA) T2CON_2 ;
__sbit __at (0xCB) T2CON_3 ;
__sbit __at (0xCC) T2CON_4 ;
__sbit __at (0xCD) T2CON_5 ;
__sbit __at (0xCE) T2CON_6 ;
__sbit __at (0xCF) T2CON_7 ;
__sbit __at (0xC8) CP_RL2 ;
__sbit __at (0xC9) C_T2 ;
__sbit __at (0xCA) TR2 ;
__sbit __at (0xCB) EXEN2 ;
__sbit __at (0xCC) TCLK ;
__sbit __at (0xCD) RCLK ;
__sbit __at (0xCE) EXF2 ;
__sbit __at (0xCF) TF2 ;
#endif
PyTorch 中 选择指定的 GPU
PyTorch默认使用从0开始的GPU,如果GPU0正在运行程序,需要指定其他GPU。
有如下两种方法来指定需要使用的GPU。
1. 类似tensorflow指定GPU的方式,使用CUDA_VISIBLE_DEVICES。
1.1 直接终端中设定:
CUDA_VISIBLE_DEVICES=1 python main.py
1.2 python代码中设定:
这里是在主函数入口处设置
import os
os.environ["CUDA_VISIBLE_DEVICES"] = "2"
2. 使用函数 set_device
import torch
torch.cuda.set_device(id)
本文详细介绍在Mac环境下安装配置51单片机开发环境的过程,包括安装sdcc编译器、CH341驱动及stcgal烧录工具等关键步骤,并提供了一个简单的测试程序实例。
1万+

被折叠的 条评论
为什么被折叠?



