Forum Index
HomeZBasic Home   Forum RulesForum Rules   Forum FAQForum FAQ   MemberlistMemberlist   UsergroupsUsergroups   RSS FeedRSS Feed
LinksLinks   DownloadDownload   Digests and SubscriptionsDigests and Subscriptions
ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in   RegisterRegister
Arduino Mega2560 board => ZBasic

 
Post new topic   Reply to topic    Forum Index -> ZBasic for Generic Targets
Author Message
petervanlievenoogen



Joined: 11 Oct 2007
Posts: 5
Location: Belgium

Posted: 31 January 2014, 12:08 PM    Post subject: Arduino Mega2560 board => ZBasic Reply with quote

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 Smile
Back to top
dkinzer
Site Admin


Joined: 03 Sep 2005
Posts: 2991
Location: Portland, OR

Posted: 31 January 2014, 15:44 PM    Post subject: Re: Arduino Mega2560 board => ZBasic Reply with quote

petervanlievenoogen wrote:
Is it possible to use the ZBasic compiler for [the Arduino Mega2560] board with a Generic licence?
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 there a guide line to change the bootloader to ZBasic?
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:
http://arduino.cc/en/Tutorial/ArduinoISP

petervanlievenoogen wrote:
Can I try this with the evaluation license?
Yes. The evaluation license is identical to the purchased license except that it is time-limited.
Back to top
petervanlievenoogen



Joined: 11 Oct 2007
Posts: 5
Location: Belgium

Posted: 01 February 2014, 14:53 PM    Post subject: Reply with quote

Thank you dkinzer,

I will try it on my board.

regards
Peter
Back to top
cerickson



Joined: 20 May 2008
Posts: 45
Location: Waikoloa Village, HI, USA

Posted: 10 August 2015, 22:50 PM    Post subject: Re: Arduino Mega2560 board => ZBasic Reply with quote

dkinzer wrote:
petervanlievenoogen wrote:
Is it possible to use the ZBasic compiler for [the Arduino Mega2560] board with a Generic licence?
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 there a guide line to change the bootloader to ZBasic?
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:
http://arduino.cc/en/Tutorial/ArduinoISP

petervanlievenoogen wrote:
Can I try this with the evaluation license?
Yes. The evaluation license is identical to the purchased license except that it is time-limited.


Are there any changes to the Arduino Mega 2560 board that are required to convert it to Zbasic?

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.
Back to top
dkinzer
Site Admin


Joined: 03 Sep 2005
Posts: 2991
Location: Portland, OR

Posted: 28 August 2015, 21:56 PM    Post subject: Reply with quote

Sorry for overlooking your questions. Did you get it going or do you still need some hints?
Back to top
cerickson



Joined: 20 May 2008
Posts: 45
Location: Waikoloa Village, HI, USA

Posted: 29 August 2015, 5:11 AM    Post subject: Reply with quote

dkinzer wrote:
Sorry for overlooking your questions. Did you get it going or do you still need some hints?


I still have my three questions.
Back to top
dkinzer
Site Admin


Joined: 03 Sep 2005
Posts: 2991
Location: Portland, OR

Posted: 29 August 2015, 22:57 PM    Post subject: Re: Arduino Mega2560 board => ZBasic Reply with quote

cerickson wrote:
Are there any changes to the Arduino Mega 2560 board that are required to convert it to 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 special compiler directives required to run Zbasic on the Arduino Mega 2560?
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.

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:
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
This set of device parameters was generated using the "Target Options" dialog, available via the Options|Target Options menu item after you've selected the target generic device. See Section 9.6 Setting Target Options for more information.

cerickson wrote:
Are there any special limitations or considerations involved with running Zbasic on an Arduino Mega 2560?
The only limitations are those imposed by the device itself and its main clock frequency.

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:
Option DeviceParameter ZBasicBootloader true
Back to top
cerickson



Joined: 20 May 2008
Posts: 45
Location: Waikoloa Village, HI, USA

Posted: 30 August 2015, 3:16 AM    Post subject: Reply with quote

Thanks!
Back to top
kurakaira



Joined: 21 Mar 2007
Posts: 68
Location: Finland

Posted: 23 May 2017, 17:27 PM    Post subject: Generic Mega2560 Reply with quote

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 . . .


Code:
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
Back to top
dkinzer
Site Admin


Joined: 03 Sep 2005
Posts: 2991
Location: Portland, OR

Posted: 11 August 2017, 2:27 AM    Post subject: Re: Generic Mega2560 Reply with quote

kurakaira wrote:
115200 does not work for my boards , is it a generic target issue or something i have overlooked ?
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.

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.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Forum Index -> ZBasic for Generic Targets Time synchro. with the server - Timezone/DST with your computer
Page 1 of 1

 


All content Copyright © 2005-2017 Elba Corp. All rights reserved.
Opinions expressed in posts are those of the author and not necessarily those of Elba Corp.
Powered by phpBB © 2001, 2005 phpBB Group