You will need to program the Nano with the ZBoot bootloader. The Nano uses a 16MHz clock which is not completely compatible with the standard settings for ZBasic.
You will need to recompile the ZBoot bootloader to be compatible with a 16 Mhz compatible communication speed. I selected 125000 baud. In the file makeboot.bat you will need to edit some settings.
Use set
Code: Select all
set F_CPU=16000000
Code: Select all
set BAUD=125000
Code: Select all
set DEVICE=mega328p
Code: Select all
// Uncomment this line to use the USART's 2x mode.
//#define USE_USART_2X
You will need to check and possibly modify some fuses on the Nano's CPU.
Brownout is set to 2.7V on mine and that seems fine. You could also select 4.xV
Bootsz is 1024 words with Address $3C00 on a 328P CPU
Bootrst should be checked.
Then the last is to set the SUT_CKSEL to "Ext Crystal Osc 8.0 - MHz; Startup time PWRDOWN/RESET: 258clk/14clk + 4.1 ms". This was very important in my experience. The default setting was a much longer startup time which appears to be too long for the ZBasic IDE. It would fail to communicate with the bootloader. The faster startup time allows proper communication.
Then in your ZBasic Programs, you will need to let the compiler know what to do. Here are the options I used at the top of the first ZBasic file:
Code: Select all
Option Signon Off
Option TargetDevice ATmega328P
Option DeviceParameter package "PDIP-28"
Option DeviceParameter clockFrequency 16000000
Option DeviceParameter rtcFrequency 500
Option DeviceParameter rtcScale 1
Option DeviceParameter swUartDivisor 8
Option DeviceParameter swUartMinSpeed 300
Option DeviceParameter swUartMaxSpeed 19200
Option DeviceParameter swUartBaseSpeed 2400
Option DeviceParameter timerSpeed1Divisor 1
Option DeviceParameter timerSpeed2Divisor 8
Option DeviceParameter ZBasicBootloader True
Click "Options" on the menu, then select "Open User Options File"
Look for the line
Code: Select all
debug.speed=115200
Code: Select all
debug.speed.list=300,600,1200,2400,4800,9600,14400,19200,28800,38400,50000,57600,76923,100000,115200,125000,230400,250000,460800,500000
Code: Select all
download.speed=115200
Other Arduino devices will need similar, but not necessarily identical changes.