自分用
以下の5ブロックを順にコードブロックに貼り付けて実行する
実行は再生マーククリックかShift+Enter
インストールスクリプト(expect使ってEnterするだけ)の作成
%%writefile /content/install_xc8.exp
#!/usr/bin/expect -f
set timeout -1
spawn sudo bash -c "/content/xc8-v3.00-full-install-linux-x64-installer.run"
while {1} {
expect {
"continue:" {
send "\n"
}
"Do you accept this license" {
send "y\n"
}
"Please choose an option" {
send "1\n"
break
}
}
}
expect "Leave unchecked for optimal compile times"
send "y\n"
expect "Installation Directory"
send "\n"
expect "Apply settings to all users of this machine"
send "y\n"
expect "Add xc8 to the PATH environment variable"
send "y\n"
expect "continue:"
send "\n"
expect "Click to purchase a PRO license"
send "n\n"
expect "Click here to get a free, 60-day evaluation of PRO"
send "n\n"
expect "Click here to activate your license"
send "n\n"
expect "Your Host ID is"
send "\n"
interact
コンパイラのインストール
!sudo apt-get update && sudo apt-get install -y expect
!wget https://ww1.microchip.com/downloads/aemDocuments/documents/DEV/ProductDocuments/SoftwareTools/xc8-v3.00-full-install-linux-x64-installer.run
!chmod +x xc8-v3.00-full-install-linux-x64-installer.run
!chmod +x install_xc8.exp
!sudo bash -c "/content/install_xc8.exp"
コードの作成(コード内容は省略)
%%writefile /content/main.c
// ここ以降にコードを記載
#pragma config FEXTOSC = OFF // External Oscillator Selection (Oscillator not enabled)
#pragma config RSTOSC = HFINTOSC_64MHZ // Reset Oscillator Selection (HFINTOSC with HFFRQ = 64 MHz and CDIV = 1:1)
...省略
コンパイル(mcpuは使用cpuに合わせる)
!/opt/microchip/xc8/v3.00/bin/xc8-cc -mcpu=18F26Q84 main.c -o demo2.hex
ダウンロード
!cat demo2.hex