Conversion of BasicX code to ZBasic
Conversion of BasicX code to ZBasic
Hi,
I've working code on a BasicX that I wanted to use with ZX-24a. The code is in three files: LCD2x16Demo.bas; LCD2x16API.bas; and LDCSerialPort.bas.
I can successfully compile the last one with only complain of a missing main(), but the other two cannot successfully compile due to calls to functions in the others. I get a list several errors - all starting with "Error: reference to undefined identifier ".......
I do have Options Language BasicX included.
What am I missing?
I've working code on a BasicX that I wanted to use with ZX-24a. The code is in three files: LCD2x16Demo.bas; LCD2x16API.bas; and LDCSerialPort.bas.
I can successfully compile the last one with only complain of a missing main(), but the other two cannot successfully compile due to calls to functions in the others. I get a list several errors - all starting with "Error: reference to undefined identifier ".......
I do have Options Language BasicX included.
What am I missing?
The Taiwanese
Re: Conversion of BasicX code to ZBasic
Generally speaking, you don't need this option unless you want to produce code that can also be compiled on the BasicX platform. With it, you'll get compiler errors if you use elements of ZBasic that aren't supported in BasicX.G Herzog wrote:I do have Options Language BasicX included.
The only effects that Option Language BasicX has on code generation are:
- Different precedence for some operators. This can change the order of evaluation of complex expressions in the absence of parentheses.
- The result of the Mod operator is always positive irrespective of the signedness of the operands.
- With Strict mode off, a hexadecimal constant with bit 15 being 1 will be considered a negative value, i.e. &Hffff0000 will be ORed with the value to produce the internal 32-bit value.
Are you using the original BasicX project file (.bxp) or did you create a new ZBasic project file (.pjt)? If the latter, check to be sure that all the .bas files are mentioned in the .pjt file.G Herzog wrote:What am I missing?
It is possible that you're using some aspect of BasicX that we haven't encountered before. So far, we haven't seen a valid BasicX application that couldn't be compiled without errors using the ZBasic compiler. If you would send me the files we can probably determine the cause of the problem in short order.
- Don Kinzer
Thanks for the quick reply. I made some headway.
I now see that Project heading has its own Compile and Go commands and I was opening individual files and compiling them separately.
I get a successful compile and load, but I have yet to achieve proper output to the serial LCD, a legacy from Netmedia and the BX-24. There was only one error message due to a Do/Loop followed by an End Sub. I removed the End Sub and the message ceased.
At this point I need to do some housekeeping and migrate a copy of the BasicX code to a directory for ZBasic specific adaptation as I have both BX-24s and ZX-24s to live with.
After that, I'll re-examine the code for reasons that the Com3 port may not initialize.
All 3 modules are Options Language BasicX, but there appears to be something in the Define Com3 or in initializing I/O pins that I've overlooked.
I have always have great difficulty understanding the BasicX documentation. While ZBasic documents are much more concise, I still suspect I am overlooking something obvious.
I now see that Project heading has its own Compile and Go commands and I was opening individual files and compiling them separately.
I get a successful compile and load, but I have yet to achieve proper output to the serial LCD, a legacy from Netmedia and the BX-24. There was only one error message due to a Do/Loop followed by an End Sub. I removed the End Sub and the message ceased.
At this point I need to do some housekeeping and migrate a copy of the BasicX code to a directory for ZBasic specific adaptation as I have both BX-24s and ZX-24s to live with.
After that, I'll re-examine the code for reasons that the Com3 port may not initialize.
All 3 modules are Options Language BasicX, but there appears to be something in the Define Com3 or in initializing I/O pins that I've overlooked.
I have always have great difficulty understanding the BasicX documentation. While ZBasic documents are much more concise, I still suspect I am overlooking something obvious.
Last edited by G Herzog on 09 May 2010, 9:58 AM, edited 1 time in total.
The Taiwanese
Here are the files you requested in a Zip file.
- Attachments
-
- BXtoZXcode.zip
- (4.15 KiB) Downloaded 948 times
The Taiwanese
I ran some more checking. The ZX24a is compiling and downloading properly.
Without going into a lot of detail, I can state that I am pretty sure that the problems I have are in the COM3 port initialization or timing of delays in the LCD intialization.
The software is suppose to present a clock on the LCD and cycle 4 relays at 1 second intervals. (The clock gets updated every 4-5 seconds) The code I presented to you didn't cycle the relays (just had the clock running), but I corrected that and now have the clock display and relay in the same Do Loop in Main().
At this point, when using the BX24 the display and relays cycle nicely, but on the ZX24a the display is not initialized while the relays cycle correctly.
That seems to indicate the ZX24a is running through the whole program, but proper communication is NOT reaching the serial LCD.
Let me know if you find the problem before I do. It may be the Baud rate is miscalculated or initialization delays have been halved by using the same code on a ZX24a.
Without going into a lot of detail, I can state that I am pretty sure that the problems I have are in the COM3 port initialization or timing of delays in the LCD intialization.
The software is suppose to present a clock on the LCD and cycle 4 relays at 1 second intervals. (The clock gets updated every 4-5 seconds) The code I presented to you didn't cycle the relays (just had the clock running), but I corrected that and now have the clock display and relay in the same Do Loop in Main().
At this point, when using the BX24 the display and relays cycle nicely, but on the ZX24a the display is not initialized while the relays cycle correctly.
That seems to indicate the ZX24a is running through the whole program, but proper communication is NOT reaching the serial LCD.
Let me know if you find the problem before I do. It may be the Baud rate is miscalculated or initialization delays have been halved by using the same code on a ZX24a.
Last edited by G Herzog on 09 May 2010, 23:01 PM, edited 1 time in total.
The Taiwanese
Oddly, your code runs fine on a ZX-24 connected to an LCD2x16 but not when compiled for a ZX-24a. I haven't figured out why but it works fine on the ZX-24a if I switch the wiring to use the Rx/ input and change the configuration byte on the call to DefineCom3() to bx0000_1000 to match.G Herzog wrote: I am pretty sure that the problems I have are in the COM3 port initialization or timing of delays in the LCD intialization.
I don't have a circuit diagram for the interface board of the older LDC2x16 that I have but there is something odd going on.
- Don Kinzer
Thanks for looking into this. I'll see if your changes work for me as well. Using the inverted Rx is fine if it works.
I don't have documentation in digital form for the older LCD2X16 either, but I may be able to locate a hard copy somewhere around here. If I can, I can scan it and forward it to you.
I don't have documentation in digital form for the older LCD2X16 either, but I may be able to locate a hard copy somewhere around here. If I can, I can scan it and forward it to you.
Last edited by G Herzog on 09 May 2010, 22:40 PM, edited 1 time in total.
The Taiwanese
I located "NetMedia 2x16 Serial LCD Display Module V1.5". I am not sure there is much useful information to explore.
The document only offers hook up schematics - nothing of the internal setup of the LCD2x16.
The Example Program on page 7 has DefineCom3(0,5,bx1000_1000)
I am a bit unclear of how you adapted the hardwire of RX/. JP5 has pins designated as follows:
1. Gnd
2. +5
3. Rx
4. Rx/
5. LEDSV+
Did you divert Pin4 Rx/ to the board's socket mate to Pin 3 (feeds Pin 5 on the ZX-24a) while disconnecting Pin 3 Rx? And, should I be bothering with this or just wait for you to sort out a fix in firmware code?
It seems that one would have to put a scope on the Tx (Pin 5of the ZX-24) to see if it is out of spec or if there is a bug within the LCD2x16 firmware (which you can't fix). I don't have a real scope available. If I must I can run a set up through my computer's audio card for this, but it may not provide conclusive info.
The document only offers hook up schematics - nothing of the internal setup of the LCD2x16.
The Example Program on page 7 has DefineCom3(0,5,bx1000_1000)
I am a bit unclear of how you adapted the hardwire of RX/. JP5 has pins designated as follows:
1. Gnd
2. +5
3. Rx
4. Rx/
5. LEDSV+
Did you divert Pin4 Rx/ to the board's socket mate to Pin 3 (feeds Pin 5 on the ZX-24a) while disconnecting Pin 3 Rx? And, should I be bothering with this or just wait for you to sort out a fix in firmware code?
It seems that one would have to put a scope on the Tx (Pin 5of the ZX-24) to see if it is out of spec or if there is a bug within the LCD2x16 firmware (which you can't fix). I don't have a real scope available. If I must I can run a set up through my computer's audio card for this, but it may not provide conclusive info.
Last edited by G Herzog on 10 May 2010, 5:01 AM, edited 1 time in total.
The Taiwanese
Hi again,
By diverting to the Rx/ pin on the LCD2X16 and recompiling the code in DefineCom3, I've managed to get this 100% functioning. In other words, I replicated your suggested quick fix.
As it is, the setup is under a 'jury rig'. Before I start to move hardware around and consider this the best I can do, I will wait a few days to see if this is a bug in the firmware that you might easily remove.
I am leaving May 14th for Thailand for 3 weeks and had put this together as a gift for the fellow I am visiting. Since I now have a useful working demo and a way to make a stable hardware configuration, you are welcome to take your time figuring this out. It was really important to me that he receive a ZX-24a rather than a BX-24 as your information and support are superior.
It seems to me that the Inverted option in DefineCom3 is buggy, maybe the same for DefineCom.
If you get a fix this week, I'll reload the firmware and revert to the intended hardware setup. If you don't I'll rewire the LCD2x16 to always use the Rx/ pin and it can run forever in the alternative configuration. We can always install a firmware revision weeks later.
I'll watch for entries here on your final solution.
Thanks. George
By diverting to the Rx/ pin on the LCD2X16 and recompiling the code in DefineCom3, I've managed to get this 100% functioning. In other words, I replicated your suggested quick fix.
As it is, the setup is under a 'jury rig'. Before I start to move hardware around and consider this the best I can do, I will wait a few days to see if this is a bug in the firmware that you might easily remove.
I am leaving May 14th for Thailand for 3 weeks and had put this together as a gift for the fellow I am visiting. Since I now have a useful working demo and a way to make a stable hardware configuration, you are welcome to take your time figuring this out. It was really important to me that he receive a ZX-24a rather than a BX-24 as your information and support are superior.
It seems to me that the Inverted option in DefineCom3 is buggy, maybe the same for DefineCom.
If you get a fix this week, I'll reload the firmware and revert to the intended hardware setup. If you don't I'll rewire the LCD2x16 to always use the Rx/ pin and it can run forever in the alternative configuration. We can always install a firmware revision weeks later.
I'll watch for entries here on your final solution.
Thanks. George
The Taiwanese
It is possible that there is a problem with inverted mode but the signal looked exactly as I expected it to be on a logic analyzer. I have some ideas for additional confirmation tests.G Herzog wrote:It seems to me that the Inverted option in DefineCom3 is buggy, maybe the same for DefineCom.
DefineCom3() is implemented by the compiler by emitting the same code as for DefineCom(3, ...). Consequently, any defect in DefineCom() would also exist in DefineCom3().
- Don Kinzer
And, indeed, there was. The problem was introduced in the VM version 3.0.0 but it does not affect VM devices based on the mega32. The same problem exists in the ZX Library versions beginning with v3.0.0.dkinzer wrote:It is possible that there is a problem with inverted mode [...]
VM updates for the affected devices as well as an updated ZX Library are available on the Downloads Page. A new installer with the updated ZX Library has been put on the server as well.
If you have a ZX device with VM version v3.0 or later, you'll need to install the VM update. Be sure to read the changes.txt if you have a ZX-1280 or ZX-1281 with VM v3.0.3 because a special update procedure will have to be used.
If you have a native mode ZX device and you're using v3.0.0 or later of the ZX Library, you'll want to download the .zip file with the updated ZX Library files from the Downloads Page.
- Don Kinzer