Compiling for Arduino 328 target

Questions and discussion about the ZBasic IDE.
Post Reply
spamiam
Posts: 739
Joined: 13 November 2005, 6:39 AM

Compiling for Arduino 328 target

Post by spamiam »

I see that the newest IDE/Compiler seems to have the ability to compile for an arduino target. I have some Nano clones that I might be able to use.

I selected the ZA-328 as the target for the compiler. When I compiled my pre-existing code (used for a generic ATMeg-328P, 16 MHz), I received the following error message:

Internal error: device.cpp(3118), Rev $Rev: unexpected pin table entry

What did I do wrong? As far as I know, I do not refer to Arduino pins, instead I refer to CPU ports and bits (e.g. C.4).

To run some ZBasic code on an arduino, do I need to install a ZBasic bootloader on it (does this turn it into a "generic" ZBasic device, or maybe "Native"?) or can it use the Arduino Optiboot?

-Tony
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: Compiling for Arduino 328 target

Post by dkinzer »

spamiam wrote:What did I do wrong? As far as I know, I do not refer to Arduino pins, instead I refer to CPU ports and bits (e.g. C.4).
That is difficult to say without looking at your code. If you'll send it to me so that I can compile the project I can determine what is happening.
spamiam wrote:To run some ZBasic code on an arduino, do I need to install a ZBasic bootloader on it [...]?
You will need the ZBasic bootloader and you can build one using the files on the zboot directory. Essentially, the Arduino device targets are standardized generic target devices for which the special license is not required (similar to the ESP8266 in that regard).
- Don Kinzer
spamiam
Posts: 739
Joined: 13 November 2005, 6:39 AM

Post by spamiam »

Thanks Don,

I will send you the source code for you to try.

My ZBasic installation is a fresh brand new installation on a Win10 laptop. I originally developed the program on my Win7 desktop running an OLD version of the compiler and IDE. I have been compiling there using the generic 328P as the target.

The target has a Zbasic bootloader and runs at 16MHz (with a resonator), but it is otherwise a pretty standard platform for ZBasic and Arduino.

What would be the proper target for an Arduino Nano (ATMega328) modified with the ZBasic bootloader?

Also, once I install the ZBasic bootloader, then it will not follow the Arduino Optiboot download protocol. I see mention being made of the ability to tell the IDE to use arduino protocol for download? Is that correct? If so, under what circumstances would that happen?

-Tony
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Post by dkinzer »

spamiam wrote:What would be the proper target for an Arduino Nano (ATMega328) modified with the ZBasic bootloader?
As long as it is a standard 16MHz mega328P-based Arduino you would use ZA-328 as the target.
spamiam wrote:I see mention being made of the ability to tell the IDE to use arduino protocol for download?
Where did you see that?
- Don Kinzer
spamiam
Posts: 739
Joined: 13 November 2005, 6:39 AM

Post by spamiam »

Hmmmm... Good Question!

I thought it was in one of the manuals for ZBasic. But I don't see it now. As I recall, it was a chart showing a few ATMega processors in one column and then another column listing Optiboot, and maybe another bootloader as some sort of option for that CPU.

But the chart did not make immediate sense to me as to how that would relate to compiling and loading the program to a CPU. I will have to check on this further to see what in the world I was possibly seeing and thinking!

-Tony
spamiam
Posts: 739
Joined: 13 November 2005, 6:39 AM

Post by spamiam »

Don,
By the way, I see the ZA-328 as a listed target. i was assuming that the "A" in the name means Arduino. But I do not see any info on the "ZA" devices in the reference manuals. Did I miss it?

Is it choosing the ZA-328 as the target that will create "generic" type code without requiring a "generic" mode license, whereas compiling for the ATMega328P WILL require the generic license?

Other than potentially not requiring a generic license, what is the functional difference between compiling for the ZA-328 and the ATMega328?

-Tony
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Post by dkinzer »

spamiam wrote:i was assuming that the "A" in the name means Arduino.
You assumed correctly. The support was added due to the widespread use of the Arduino devices and in preparation for a particular third party application that did not proceed. It was left in but not documented.
spamiam wrote:Is it choosing the ZA-328 as the target that will create "generic" type code without requiring a "generic" mode license, whereas compiling for the ATMega328P WILL require the generic license?
Yes, but of course the Arduino devices are a specific generic target (e.g. processor speed, etc.). One could compile an application for the ZA-328 and run the code on a hardware platform of their own design as long as the pertinent parameters match the Arduino devices.
- Don Kinzer
spamiam
Posts: 739
Joined: 13 November 2005, 6:39 AM

Post by spamiam »

Ah, a stillborn third party device. That explains the undocumented target!

So, it assumes 16Mhz on the CPU. What are the RTC settings and other parameters it will use? Would it be what I would generate in the "Target options" window?

E.G. ZBasic bootloader, MLF-32, 16MHZ, RTC enabled, 500 Hz RTC feq?

BTW, I found the page that confused me a little about the IDE possibly being able to boot load to an Arduino:

http://www.zbasic.net/Arduino-Devices.html

After reading this again, it appears that you are selling the CPUs listed, with the Arduino bootloaders pre-installed? For some reason I thought you were saying that these devices could be used with the ZBasic IDE....

-Tony
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Post by dkinzer »

spamiam wrote:What are the RTC settings and other parameters it will use?
rtcFrequency = 500Hz, package=PDIP-28

The fact that the 28-pin package is assumed may be the origin of the issue you saw.
spamiam wrote:After reading this again, it appears that you are selling the CPUs listed, with the Arduino bootloaders pre-installed?
That is correct, they are devices with the Arduino bootloader installed.
- Don Kinzer
spamiam
Posts: 739
Joined: 13 November 2005, 6:39 AM

Post by spamiam »

I do not know for a fact that the ZA-328 is assuming the 28 or 32 pin package. As I recall the 32 pin has 2 extra analog-only pins and I am not using those in the project in question.

For my needs it is not critical to have the ZA-328 target function properly because I have a generic license. And maybe you do not want to spend time getting a target to compile properly (or work out the cause of the error) when that target does not actually exist in real life (other than user-modified Arduinos)
Post Reply