• AVR Freaks

Hot!Minibasic for Pic32

Page: << < ..11 Showing page 11 of 11
Author
ErnieM
Super Member
  • Total Posts : 375
  • Reward points : 0
  • Joined: 2007/10/13 02:54:02
  • Location: 0
  • Status: offline
RE: Minibasic for Pic32 2010/10/24 16:20:15 (permalink)
0
Non-integer (just i) seems to work as expected.  Here is the basic script. All is well if I remove the "%" from "i%"
[code]
"10 FOR i%=1 TO 3\n"
"20 A$ = HEX$(i%)\n"
"30 PRINT \"Value is \"; A$\n"
"40 NEXT i%\n"   
"60 PRINT \"GOOD BYE\"\n"
[\code]

(I don't believe I just posted BASIC code here.)

Program output:

Value is 0
Value is 1
Value is 2
Value is 3
GOOD BYE
<program fault: unmatched for?>

So there are two problems: uninitiated variable, and the NEXT doesn't end cleanly.


DarioG
Allmächtig.
  • Total Posts : 54081
  • Reward points : 0
  • Joined: 2006/02/25 08:58:22
  • Location: Oesterreich
  • Status: offline
RE: Minibasic for Pic32 2010/10/25 01:18:52 (permalink)
0
Ok. Will take a look, definitely a matter of the % thing, added at a later time (and also removable via #define while compiling).

thank you!

GENOVA :D :D ! GODO
DarioG
Allmächtig.
  • Total Posts : 54081
  • Reward points : 0
  • Joined: 2006/02/25 08:58:22
  • Location: Oesterreich
  • Status: offline
RE: Minibasic for Pic32 2010/10/25 01:52:04 (permalink)
0
Ok, my current version works correctly - I suppose you found an older one.

Download it at
http://cyberdyne.homeip.net/public/minibasic.zip

(currently compiled for a PIC24, without LCD)

GENOVA :D :D ! GODO
ErnieM
Super Member
  • Total Posts : 375
  • Reward points : 0
  • Joined: 2007/10/13 02:54:02
  • Location: 0
  • Status: offline
RE: Minibasic for Pic32 2010/10/25 08:03:13 (permalink)
0
Awesome, that fixed the integer FOR/NEXT problem.

FYI, I could not open any of the workspaces or project files, any of these would crash MPLAB right off. My workaround was to re-create a project and manually add everything in. I built it for a PIC32MX460F512L and it compiled with no issues.

Then I added in my changes in the PRINT routine to get it to work with my GLCD thru LCDTerminal.c.

This is going to be lots of fun!



DarioG
Allmächtig.
  • Total Posts : 54081
  • Reward points : 0
  • Joined: 2006/02/25 08:58:22
  • Location: Oesterreich
  • Status: offline
RE: Minibasic for Pic32 2010/10/25 08:07:56 (permalink)
0
Good it is working now, and keep up with reporting issues Smile !

That's strange since I'm using latest MPLAB, quite short pathnames so... am not sure about the problem...
Oh well, don't matter.

The "hardware library" would need some extending, say Timers etc. But a USB-HID simple I/O stream would be useful.. !

GENOVA :D :D ! GODO
ErnieM
Super Member
  • Total Posts : 375
  • Reward points : 0
  • Joined: 2007/10/13 02:54:02
  • Location: 0
  • Status: offline
RE: Minibasic for Pic32 2010/10/30 10:02:03 (permalink)
0
I guess it is time for an update. Sorry the code is in no form to be shared yet but here is my direction.

I am cutting minibasic.c away from the main application, so it can be included into an arbitrary project. That is still a work in progress as I still have some code hacked in there. My intent is to define a set of platform custom routines (such as how & where doprint() actually prints) so anyone can add in their specific platform.

In general, here is what I have in the done bucket:

I have my 320x240 GLCD running LCD terminal so it displays on 11 lines of 26 characters so I can see output (and the small test scripts for the moment).

Added file system support. currently it auto loads a program (autoexec.bas) when it runs.

Added full white space support, meaning spaces AND tabs may be placed anywhere, as can blank lines, or even lines just containing tabs and/or spaces. Lines may be terminated by either /n or /r/n (as notepad does) without causing errors.

Script is now parsed somewhat differently as it needs to be read off the SD card line by line into a buffer. This means there is a 1-1 correspondence between chunks and lines of text.

I used this 1-1 correspondence to add line labels and remove all line numbering. So far this is only added into GOTO and a direct GOSUB statement. This was accomplished by adding a list of LABLEITEMS that keep the line number, character count, and offset of the label string in the script file, filled as the script is run. Should a label destination be needed, the LABLEITEMS list is walked first to find a character count match (which is pretty fast), then loading the string from the script for an actual comparison (which is slower but effective).

I'm still reverse engineering how some of the function work (especially dolet!) but once I get them down the next step is to add subroutine and then function support. Subs seem easier as there is no return value, but I do want to make local variables. In fact, I'll probably make variable definition a strict requirement as I sense this will ease local variable creation & destruction.

 
rem this is a remark
' is this also a remark
place0: print "123"
    gosub place1   
    print "456" ' remarks here too!
    end

place1:
    print "789"
    return


That script has the following output:
 
123
789
456
Done.




post edited by ErnieM - 2010/11/03 12:02:20
jarin
Super Member
  • Total Posts : 848
  • Reward points : 0
  • Joined: 2005/05/23 13:50:02
  • Status: offline
RE: Minibasic for Pic32 2010/10/31 03:29:09 (permalink)
0
Ernie, nice work.
Hope you will release some code, and I believe I'm not the only one (and Dario too, of course) who is interested in this topic.

Jaromir Sukuba, Bratislava, Slovakia
http://jaromir.xf.cz/  - open source PIC18 debugger.
DarioG
Allmächtig.
  • Total Posts : 54081
  • Reward points : 0
  • Joined: 2006/02/25 08:58:22
  • Location: Oesterreich
  • Status: offline
RE: Minibasic for Pic32 2010/11/01 04:42:19 (permalink)
0
Nice Smile

Yeah, label instead of numbers was one big wish; locals, another one Smile ; running from File instead than from Array was of course a logical step once a SD or alike is added, or anyway multiple sources are in place.

I/O redirecting such as PRINT # or alike was almost in progress.

And I would not forget about USB or Ethernet support which may make that all "more useful" !

GENOVA :D :D ! GODO
ErnieM
Super Member
  • Total Posts : 375
  • Reward points : 0
  • Joined: 2007/10/13 02:54:02
  • Location: 0
  • Status: offline
RE: Minibasic for Pic32 2010/11/10 15:17:14 (permalink)
0
Progress Report: Been hacking away at this beast now for another week plus and think I am getting somewhere good! My goal has always been to extend the existing code base while making as little change to it as possible, as it already has some very good features. OK, so line numbers are out and line labels are in. Variables & types are still declared implicitly but this will soon change.

Right now I'm not so concerned with making it run any particular hardware. Hey, we're all smart guys and we add another statement or 12 to set up an I2C or USB or whatever and make it sing. I've been working to make this a better tool at its core.

The biggest feature this code needs is subroutine & function support and I have been working on those. To get a full featured sub & function meant taking a step back and adding BYREF variables, as these are just so usefull to ignore and adding them earlier seemed smart. To make the change as incrmental as possible I took the existing VARIABLE definition and added the BYREFID type, and a VARIABLE reference to another VARIABLE. This way a searching for a variable by name leads directly to the deferenced base variable, no matter what the Name Space is. To test the concept I added the nearly useless "BYREF var1, var2" command which creates a reference variable. ie, if you declare

a%=1
BYREF b% a%

then both a% and b% refer to the same variable.
Wait a sec, did someone say Name Space? Note that every VARIABLE in the array holds reference to it's name. I've added a second VARIABLE array named LocalVariables, which starts NULL. When a variable is searched for it is first checked in the LocalVariables array, and if not found then checked in variables, which now contains only the global variables. When creating a variable, they are created in the LocalVariable space if such exists, if not then created in the existing variables array.

This is all used in the new command CALL <label> statement. OK, no variable passing yet but that's the next step. Kicking off a CALL will save any existing LocalVariables plus several other global symbols the line() function needs (that's the function that parses out and actually performs the script). The Call routine then create & install a new LocalVariable set, then run the sub script itself. Yes, the Call routine has another copy of the script loop as the Basic subroutine also has. Once the CALL script returns (ENDSUB) the LocalVariable context is replaced with the one it replaced. This way a sub can call another sub and so on, each one getting it's own local context to play in.

While not demonstrated, since CALL saves the existing context then another CALL within a CALL should just keep drilling down keeping the Name Spaces separate and under control.

To demonstrate that, here's my latest test program:

a% = 10
b% = 20
c% = 30
print "1:A=",a%;" B=",b%;" C=",c%
call Test1    ' subroutine call!
print "3:A=",a%;" B=",b%;" C=",c%
end

SUB Test1
    byref c% a%    ' local alias
    b% = 60        ' assign to the global   
    c% = 50        ' assign to the local alias
                         '  but NOT to the global
    print "2:A=",a%;" B=",b%;" C=",c%
SUBEND


And it's output is this:

1:A=10    B=20    C=30
2:A=50    B=60    C=50
3:A=50    B=60    C=30


Note that in the sub that since c% was declared BYREF to a% that changing c% there also changes the global a%. Also note that since the new variable b% is created in the local context we also get local variables for almost free!

So far it is hack code, no error checks along the was so a bad script can crash the machine, local strings are not freed, dimensioned variable are completely ignored.

Hey, its a work in progress, I took a big step with it today and I am happy with these results.

Once I get the rest of subroutines and functions up and running I will release the code.
DarioG
Allmächtig.
  • Total Posts : 54081
  • Reward points : 0
  • Joined: 2006/02/25 08:58:22
  • Location: Oesterreich
  • Status: offline
RE: Minibasic for Pic32 2010/11/10 15:28:38 (permalink)
0
thanks Smile !

GENOVA :D :D ! GODO
ErnieM
Super Member
  • Total Posts : 375
  • Reward points : 0
  • Joined: 2007/10/13 02:54:02
  • Location: 0
  • Status: offline
RE: Minibasic for Pic32 2010/11/15 12:18:26 (permalink)
0
And now with our weekend update, here's ME:

Still puttering along with subroutines to actually pass in some parameters. Concentrating on simple integers for the moment, though real and string may also be working, just untested. Arrays will be another big job though (as have to check the array area and insure they only pass byref).  What is interesting is this code will eventually work for functions as there is already a defined space for a return value (it was easier to define a null variable then to treat a blank variable list as a special case).

Passed parameters are byval or byref for asint as real or asstring. Defaults are byval and asint.
 
Script input:

x% = 4
call TestSub(x%, 8, 15, 16, 23, 42)
print "x is now: ", x%
end
SUB TestSub (byref a1% asint, byval a2% asint, a3% asint, byval a4%, byval a5%, a6% )
    print "a1:", a1%; "a2:"; a2%, "a3:", a3%
    print "a4:", a4%; "a5:"; a5%, "a6:", a6%
    a% = 100
SUBEND


And the glorious output:

a1:4     a2:8     a3:15
a4:16    a5:23    a6:42
x is now: 100
Done.


Hold the applause for the moment. If the script is run a second time (I loop it for debugging) then it crashed where the byref variable is de-referenced. Probably an old pointer reference getting reused but have to track it down.


jarin
Super Member
  • Total Posts : 848
  • Reward points : 0
  • Joined: 2005/05/23 13:50:02
  • Status: offline
RE: Minibasic for Pic32 2010/11/16 00:21:34 (permalink)
0
Keep it going, please.
Nice to see you did such as progress.

Jaromir Sukuba, Bratislava, Slovakia
http://jaromir.xf.cz/  - open source PIC18 debugger.
ErnieM
Super Member
  • Total Posts : 375
  • Reward points : 0
  • Joined: 2007/10/13 02:54:02
  • Location: 0
  • Status: offline
RE: Minibasic for Pic32 2010/11/16 10:01:57 (permalink)
0
OK, past the crash. For the debugging I was using a script that printed the Sub name variable. Remember that subs and functions will be the same code, just with different parsing (sub may have return values, functions must have them). So I was sticking a dummy value into the sub name variable when I created it, but forgot to set it's type. Second loop thru it picked up a byref value that when de-referenced caused the crash. Added one line to define the type and now it works nicely.

As I get deeper and deeper into this I see a real need to do a pre calculation of the token, essentially a translation from human readable to computer point-able labels. For example, in the current program when you reference a variable name the entire list of names must be checked until a match is found. Since the names are not stored anywhere but in the orgional script the script must be read section by section till the match is found. That is extremely time consuming!

A much better way would be to translate the script such that an arbitrary label is converted into it's index number of the list it lives in. That way there is no requirement for looking things up in the script beyond the current line being parsed, and a considerable speed improvement will result.

Now this translator could be either a part of minibasic.c, or it could be an app on your PC that once the script is written it can be translated, and possibly also strongly checked for syntax so you don't have to install and run it to learn things like "For without next in line XXX". Either way you get two files per script, the text based human readable one, and a tokenized read by computer only version.

Using the tokenized script would be just a few changes, mainly in areas such as the gettoken and findvariable routines. Most of the code would stay as is, which has always been my goal. I just can't contemplate reverse engineering the (most excellent but undocumented) "dolet" routine and other routines that do expression evaluation.

Onto functions next. I also see a simple way to do static function variables. Still in a fog over constants, the simplest way handles them as a special case built-in function, but constants should be locally definable (ie, each function can define "BLOB" as it needs be).

Thanks for the kind words, I will advise when a full working version is available.
ErnieM
Super Member
  • Total Posts : 375
  • Reward points : 0
  • Joined: 2007/10/13 02:54:02
  • Location: 0
  • Status: offline
RE: Minibasic for Pic32 2010/11/27 05:36:14 (permalink)
0
Completely stalled here hence no updates. Things were going well with subs & functions, had both partially working until I went to add arrays and it all fell apart. Seems somewhere along the way the array stuff broke and I wasn't testing for that so there is a major problem to fix.

Dario, if you have some free time would you check if int, real and string arrays work in your version? I think there may be a problem with int arrays.

Currently I'm dropping way back and adding a UART so I can emit a lot of data and capture it, both for watching script parsing and also to verify long test script outputs. Oops... that is the plan but I can't get a reliable COMM link established. Sometimes works great, sometimes the transmit buffer just doesn't transmit.



DarioG
Allmächtig.
  • Total Posts : 54081
  • Reward points : 0
  • Joined: 2006/02/25 08:58:22
  • Location: Oesterreich
  • Status: offline
RE: Minibasic for Pic32 2010/11/27 07:48:38 (permalink)
0
Hi Ernie, not sure I've time soon, but I can try taking a look one of these nights.

I seem to remember that that code was almost used "as was" from the original one. I had to add the "dynamic allocation" on PIC18, but on PIC32 you should be ok with the built-in one, hence no problem with that.

Will see...

GENOVA :D :D ! GODO
BernardP
New Member
  • Total Posts : 1
  • Reward points : 0
  • Joined: 2011/11/26 03:12:36
  • Location: Poitiers, France
  • Status: offline
RE: Minibasic for Pic32 2011/11/26 03:56:50 (permalink)
0
Hi DarioG,

I have found the MiniBasic for PIC32 recently at http://www.kiwacan.co.nz/pic32/minibasic/ . I am interested in the PIC18 version and I downloaded the source with date '24th Apr 2011' wich seems rather recent !

I wish to build a minimal board with a PIC18F, a crystal, and RS232 level converter (MAX232), to try to run your software. I searched in the source for PIC type and saw 18f2620.lkr => PIC18F2620, crystal frequency in serial.h and found 12 MHz for Fosc => 12 MHz crystal. Is this hardware OK for me to buy ?

But the MiniBasic.hex file included in the archive seems much older (2007-12-06), does it correspond to the 2011-04-24 source version ? I don't have the PIC18 compiler installed and I don't have any experience with it (and I would be more interested in an open-source C compiler like SDCC). Could you post a functional .hex file that you are using, just for me to try it ? It would be greatly appreciated ...
DarioG
Allmächtig.
  • Total Posts : 54081
  • Reward points : 0
  • Joined: 2006/02/25 08:58:22
  • Location: Oesterreich
  • Status: offline
RE: Minibasic for Pic32 2011/11/26 08:17:09 (permalink)
5 (1)
Hi Smile
Yeah, some minor updates went on, in time.

You can download a free (limited in time) version of C18 from Microchip, so you should be able to work it out...

In case, let me know.

As for the Crystal/Clock, I never used a 12MHz so... hmmm, more likely 48MHz if possibly a 18F4550 was used, or 40MHz for a 18F452 (with no internal Osc and a 10MHz Crystal), or 32MHz for a 18F2620 (the new ones with internal oscillator)

GENOVA :D :D ! GODO
everslick
New Member
  • Total Posts : 1
  • Reward points : 0
  • Joined: 2018/03/23 12:04:37
  • Location: 0
  • Status: offline
RE: Minibasic for Pic32 2018/03/26 05:09:19 (permalink)
0
Sorry for digging up this ancient thread. I'm currently porting MiniBasic to a different microcontroller (ESP8266 and ESP32) and have started to implement most of the (missing) BASIC features (like INKEY, GOSUB, CLS, COLOR, ...) you guys here have already done. Unfortunately all the released archives of those changes have been gone, not even the internet archives carries them.
 
Has anybody here still got a copy of the source of Mike's, Dario's and/or Ernie's improvements? It does not matter what the state of the implementations is, it does not even have to compile or run correctly. Alone, looking at the code for ideas and examples would be very helpful already. 
 
Any help is very much appreciated!
Best regards...
Clemens
pippo18
Junior Member
  • Total Posts : 22
  • Reward points : 0
  • Joined: 2018/08/16 13:02:07
  • Location: FCUK
  • Status: offline
RE: Minibasic for Pic32 2019/09/17 13:21:40 (permalink)
0
Good news (from the next world :D ) !
Now MiniBasic runs on PIC32MZ @200MHz, and even supports USB memory sticks ("pen-drive") as a Host - by means of a "reduced" (!) and improved subset of harmony.
 
Code available upon request.
pippo18
Junior Member
  • Total Posts : 22
  • Reward points : 0
  • Joined: 2018/08/16 13:02:07
  • Location: FCUK
  • Status: offline
RE: Minibasic for Pic32 2020/02/17 11:38:35 (permalink)
0
And, of course, a dsPIC33CH version (along with TFT LCD):
http://myprivatelittlepics.proboards.com/thread/43/minibasic-forgetivrea
 
Page: << < ..11 Showing page 11 of 11
Jump to:
© 2020 APG vNext Commercial Version 4.5