Arduino Mega2560 board => ZBasic
-
- Posts: 5
- Joined: 11 October 2007, 2:23 AM
- Location: Belgium
Arduino Mega2560 board => ZBasic
I have a Arduino Mega2560 board but I don't like writing in "C"
I use to work with ZX24 ZBasic.
Is it possible to use the ZBasic compiler for this board with a Generic licence?
Is there a guide line to change the bootloader to ZBasic?
Can I try this with the evaluation license?
greeting from Belgium
I use to work with ZX24 ZBasic.
Is it possible to use the ZBasic compiler for this board with a Generic licence?
Is there a guide line to change the bootloader to ZBasic?
Can I try this with the evaluation license?
greeting from Belgium
Re: Arduino Mega2560 board => ZBasic
Yes, it is. The Arduino Mega has a 6-pin IPS connector like many other Arduino boards. You can use this connector to program the bootloader or you can use it to program the application if you don't want to use a bootloader.petervanlievenoogen wrote:Is it possible to use the ZBasic compiler for [the Arduino Mega2560] board with a Generic licence?
You can find a lot of information on the Internet about how to program a bootloader into an Arduino. You will need an In-System Programmer (ISP) of some type to do this. One option is to use another Arduino for that purpose as described at the page below:petervanlievenoogen wrote:Is there a guide line to change the bootloader to ZBasic?
http://arduino.cc/en/Tutorial/ArduinoISP
Yes. The evaluation license is identical to the purchased license except that it is time-limited.petervanlievenoogen wrote:Can I try this with the evaluation license?
- Don Kinzer
-
- Posts: 5
- Joined: 11 October 2007, 2:23 AM
- Location: Belgium
Re: Arduino Mega2560 board => ZBasic
Are there any changes to the Arduino Mega 2560 board that are required to convert it to Zbasic?dkinzer wrote:Yes, it is. The Arduino Mega has a 6-pin IPS connector like many other Arduino boards. You can use this connector to program the bootloader or you can use it to program the application if you don't want to use a bootloader.petervanlievenoogen wrote:Is it possible to use the ZBasic compiler for [the Arduino Mega2560] board with a Generic licence?
You can find a lot of information on the Internet about how to program a bootloader into an Arduino. You will need an In-System Programmer (ISP) of some type to do this. One option is to use another Arduino for that purpose as described at the page below:petervanlievenoogen wrote:Is there a guide line to change the bootloader to ZBasic?
http://arduino.cc/en/Tutorial/ArduinoISP
Yes. The evaluation license is identical to the purchased license except that it is time-limited.petervanlievenoogen wrote:Can I try this with the evaluation license?
Are there any special compiler directives required to run Zbasic on the Arduino Mega 2560?
Are there any special limitations or considerations involved with running Zbasic on an Arduino Mega 2560?
I have already purchased the Zbasic Generic Target License.
Re: Arduino Mega2560 board => ZBasic
No modifications to the board itself are required but you may need to or want to change the "fuse" settings. See AN-103 - Preparing ZBasic Generic Target Devices for more details. If you're going to use a ZBasic-compatible bootloader (see discussion further below), I would recommend these fuse settings: ext=0xfd, hi=0xd6, lo=0xd7. If you're going to program your app into the device using an ISP, the Arduino Mega 2560 fuse settings of ext=0xfd, hi=0xd8, lo=0xff are probably fine.cerickson wrote:Are there any changes to the Arduino Mega 2560 board that are required to convert it to Zbasic?
Yes. From the perspective of ZBasic, the Arduino Mega 2560 is just a generic ATmega2560 so the information in Chapter 5 of the ZBasic Language Reference Manual applies.cerickson wrote:Are there any special compiler directives required to run Zbasic on the Arduino Mega 2560?
In particular, you need to specify several device parameters. Most of them derive from the main clock frequency - 16MHz on the Arduino Mega 2560. The set of device parameters below will probably work fine, just add them to the top of the primary .bas file (the one with the Main() in it). You can also specify device parameters in the .pjt file but the form is slightly different (see the discussion of the --device-parameter option).
Code: Select all
Option DeviceParameter package "TQFP-100"
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
The only limitations are those imposed by the device itself and its main clock frequency.cerickson wrote:Are there any special limitations or considerations involved with running Zbasic on an Arduino Mega 2560?
There is a question of how you're going to get the application code into the Arduino Mega 2560 device. One option is to use an AVR-compatible In-System-Programmer (ISP) device like the Atmel ATAVRISP2 (unfortunately, no longer manufactured) or equivalent. You can also use another Arduino with a special AVR ISP sketch to program AVR devices. A Google search with suitable keywords will return useful links.
Another alternative is to first install a ZBasic compatible bootloader. Source code and a build script for such a bootloader is provided in the zboot directory of the ZBasic installation directory. Of course, you need an ISP device to put the bootloader on the AVR (see the preceding paragraph) but after that you can download your application to the device in a manner similar to that used for ZX devices. If you do install a ZBasic-compatible bootloader you'll need one additional device parameter:
Code: Select all
Option DeviceParameter ZBasicBootloader true
- Don Kinzer
Generic Mega2560
Works great ,,, as long as You keep below ConsoleSpeed of 57600 ... 115200 does not work for my boards , is it a generic target issue or something i have overlooked ?
I have not tested if this affects other UART's on the Mega2560 . . .
I have not tested if this affects other UART's on the Mega2560 . . .
Code: Select all
Option TargetDevice ATmega2560
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
Option ConsoleSpeed 115200 ' 57600 works fine
Option RTC on
Option Signon on
Option TxQueueSize 100
Option RxQueueSize 40
Option Console Com1
Const Led as byte = B.7
Sub Main()
Debug.Print "Hello From 2560"
Do
Debug.Print "Hello ."
Call PutPin(Led, 1)
Call Delay(1.0)
Call PutPin(Led, 0)
Debug.Print "It Really Works :)"
Call Delay(0.5)
Loop
End Sub
Re: Generic Mega2560
At 16MHz, the mega2560 (and all other mega devices) cannot produce 115.2K baud accurately enough - the actual baud rate is about 2.1% off. That likely explains the problem you're having. Generally speaking, you need a baud rate significantly less than 2% off in order to communicate effectively.kurakaira wrote:115200 does not work for my boards , is it a generic target issue or something i have overlooked ?
If you use the Target Options dialog you can see what the error is for the various standard baud rates given a particular CPU frequency.
- Don Kinzer