• AVR Freaks

Hot!Minibasic for Pic32

Page: < 12345.. > >> Showing page 2 of 11
Author
DarioG
Allmächtig.
  • Total Posts : 54081
  • Reward points : 0
  • Joined: 2006/02/25 08:58:22
  • Location: Oesterreich
  • Status: offline
RE: Minibasic for Pic32 2007/12/04 03:59:02 (permalink)
0
Ok, here it goes Smile

http://adpm.homeip.net/files/MiniBasic.zip

(The package is complete of old/original code by Malcolm, the new code by Dan, and of course my Project/Code for PIC18).

Some points:
  • Size is 30K (90%) now (no optimizations), with USART I/O and some HW libraries. I'd like to add LCD support (files are already included, coming from older projects of mine). Code drops down to 19K with optimizations.
  • Speed: circa 3.5mSec for a FOR/POKE loop, per iteration (32MHz Oscillator)
  • Speed as per "Future56K" question: 25mSec for settling up, 10seconds (almost exact) for 10000 iterations; consistent with 1mS per iteration noted above(32MHz Oscillator)
  • Need to implement Bitwise operators, ELSE; GOSUB has been added; implicit LET has been added but untested; LOG/EXP are something I'm going to add as well; HEX$ has been added. (all done: 4/12/07)
  • ABSOLUTELY NEEDED: rewrite SRAMalloc (borrowed from MSD code by Microchip) to make it work multi-bank (at the moment, only 256 bytes are available for variables...) - help is welcome Smile (done/tried to: 4/12/07)
  • Biggest issues in porting code have been: ROM/RAM nightmare Smile, strn* routines bug (see http://forum.microchip.com/tm.aspx?m=299263 , size of code and limited RAM available
  • No extensive test have been done - need some hardware for that. Help gladly welcome.
  • Extra peripheral support can be easily added due the flexibility of code, only trouble can be the size of code (for instance, fitting this Basic on a 2550 to get easy USB support is a bit of a challenge)
  • An editor would be nice as well Smile Dan has already done that
  • with all due respect, I find the original code by Malcolm a bit inefficient and not-user-friendly, at least the way I would have done it: for instance, "LET" is needed, "?" is not supported as PRINT, no multistatement lines, Keywords need be capitalized, they are not tokenized... And a lot of "double" and "sometimes useless strings". No problem, anyway, I'm glad I had the chance to work on it!
  • changes done by Dan are nice and useful - unfortunately they make the code too large for PIC18... and actually his code chrashes C18 with a "YYLMAX" error... something funny! For the record, I came to similar optimizations, the first time I looked at Malcolm's code
Ok, I probably forgot something. Will be back soon wink

PS: to Mike: how can I do to post this all to PIC32, and how should I behave as per the licensing method? I did keep all of the Copyright in the code...
(I've just done some free projects until now, but they hardly went into a large audience...)
post edited by DarioG - 2007/12/05 08:50:20

GENOVA :D :D ! GODO
#21
EmbeddedMan
Junior Member
  • Total Posts : 112
  • Reward points : 0
  • Joined: 2005/10/15 15:08:38
  • Status: offline
RE: Minibasic for Pic32 2007/12/04 09:31:48 (permalink)
0
Dario,

I tried to build your MiniBasic.zip project, and am having problems with C18 finding the <typedefs.h> file. It doesn't appear to be included with my C18 (v3.14).

Not to stray too far from PIC32 land - I am very exited by your port of MiniBasic to the PIC world, and have a PIC32 StarterKit and would love to help test your PIC32 port of this code. I figured the first step would be to get it to build, as you do currently, with C18.

Any ideas?

Thanks!

*Brian
#22
DarioG
Allmächtig.
  • Total Posts : 54081
  • Reward points : 0
  • Joined: 2006/02/25 08:58:22
  • Location: Oesterreich
  • Status: offline
RE: Minibasic for Pic32 2007/12/04 09:48:48 (permalink)
0
Sorry, it's my "common" typedefs, based upon the one in TCPIP stack sadSmile

I'm adding it to the zip now.

GENOVA :D :D ! GODO
#23
EmbeddedMan
Junior Member
  • Total Posts : 112
  • Reward points : 0
  • Joined: 2005/10/15 15:08:38
  • Status: offline
RE: Minibasic for Pic32 2007/12/04 11:49:42 (permalink)
0
Dario,

Cool! Now I can build it - but the link step fails. I only have the student edition of C18, (so I have to turn off extended mode to build the source) so I get a ".code_sincos.o can not fit the section" error.

Oh well. I'll have to wait until it is ready for the PIC32 I guess. :-) Thanks for doing this work!

*Brian
#24
DarioG
Allmächtig.
  • Total Posts : 54081
  • Reward points : 0
  • Joined: 2006/02/25 08:58:22
  • Location: Oesterreich
  • Status: offline
RE: Minibasic for Pic32 2007/12/04 11:57:18 (permalink)
0
You're compiling for 18F2620?

It can't fit if compiled in standard mode... far too much use of local variables! Should change them to overlay... and it gets somewhat complicated.

You could try 2685, maybe.

GENOVA :D :D ! GODO
#25
lauer
Starting Member
  • Total Posts : 38
  • Reward points : 0
  • Joined: 2003/11/07 12:35:15
  • Status: offline
RE: Minibasic for Pic32 2007/12/04 12:41:53 (permalink)
0
Hi Dario,
 
you are fast. I try to compile it too for the 18F, my C18 might be out of date, something is stuck.
You don't have a  PIC32 starterkit?
You said the minibasic is not tokenised. As I understood it, when you enter the basic code, it analyses it and saves all the commands as tokens. when you then run the code it executes the saved (tokenisesd) program.
Peter
#26
DarioG
Allmächtig.
  • Total Posts : 54081
  • Reward points : 0
  • Joined: 2006/02/25 08:58:22
  • Location: Oesterreich
  • Status: offline
RE: Minibasic for Pic32 2007/12/04 12:58:07 (permalink)
0
Yeah, I had some time spare these days Smile

No, I have not downloaded PIC32 environment - I could take a look.

As for C18, if you download latest C18 and latest MPLAB, you should get it running...

And, well, it looks like the "new" code by Dan does tokenize, while the original one by Malcolm does not.
In perspective for PIC32, this latest one may be best choice: but it would not fit on a 18F, which was my aim now.

PS: I'm posting a new ZIP soon , with some slight adjustment.
I also burned a real PIC and it all works, according to timings shown by SIM !

GENOVA :D :D ! GODO
#27
Kiwi Mike AZ
Super Member
  • Total Posts : 2056
  • Reward points : 0
  • Status: offline
RE: Minibasic for Pic32 2007/12/04 17:34:44 (permalink)
0
Hi Dario,

had to change the followoing in iohw.c to get it to compile - ADC_VREF......

OpenADC(ADC_FOSC_32 & ADC_RIGHT_JUST & ADC_12_TAD, ADC_CH0 & ADC_INT_OFF & ADC_VREFPLUS_VDD & ADC_VREFMINUS_VSS ,
            ADC_1ANA /* & 0xf */ /*patch di g.dar*/);


Going to try PIC32 compile now.... will see what needs porting soon.

Mike
#28
Kiwi Mike AZ
Super Member
  • Total Posts : 2056
  • Reward points : 0
  • Status: offline
RE: Minibasic for Pic32 2007/12/04 17:41:16 (permalink)
0
PIC32 Compile Errors (summarized)

 malloc.h: No such file or directory
 Many Syntax Errors caused by     "const rom char far *"    -> No rom option in C30

`LATCbits' undeclared -> LATCbits.LATC5 ^= 1;        // test timing

No to much to port at the moment.

Mike

#29
Kiwi Mike AZ
Super Member
  • Total Posts : 2056
  • Reward points : 0
  • Status: offline
RE: Minibasic for Pic32 2007/12/04 21:42:55 (permalink)
0
OK there is a little work to do to get it running on a PIC24, dsPIC or PIC32.

Some compiler differences.

Mostly I/O handling and processor specific differences (CPU setup, ADC etc)
Also some library differences for UART etc.

When I have some time spare I will merge PIC32 and PIC24/dsPIC specifics into the files.

May be easier to do this after Dario has a stable version on the PIC18 sice we do not have a CVS (or better) setup at the moment.
Dont want to fork it this early on in its development.

post edited by mimemike - 2007/12/04 21:44:17
#30
DarioG
Allmächtig.
  • Total Posts : 54081
  • Reward points : 0
  • Joined: 2006/02/25 08:58:22
  • Location: Oesterreich
  • Status: offline
RE: Minibasic for Pic32 2007/12/05 02:26:18 (permalink)
0
ORIGINAL: mimemike
had to change the followoing in iohw.c to get it to compile - ADC_VREF......

OpenADC(ADC_FOSC_32 & ADC_RIGHT_JUST & ADC_12_TAD, ADC_CH0 & ADC_INT_OFF & ADC_VREFPLUS_VDD & ADC_VREFMINUS_VSS ,
           ADC_1ANA /* & 0xf */ /*patch di g.dar*/);



You're still using pre-3.14 C18 SmileSmile

That define about VREF was changed in the latest version of C18... and needless to say, broke all of my software!

GENOVA :D :D ! GODO
#31
DarioG
Allmächtig.
  • Total Posts : 54081
  • Reward points : 0
  • Joined: 2006/02/25 08:58:22
  • Location: Oesterreich
  • Status: offline
RE: Minibasic for Pic32 2007/12/05 02:29:06 (permalink)
0
ORIGINAL: mimemike

Some compiler differences.

Mostly I/O handling and processor specific differences (CPU setup, ADC etc)
Also some library differences for UART etc.


Yeah, agreed. Luckily they're mostly in separate files.

Also about this
Many Syntax Errors caused by     "const rom char far *"    -> No rom option in C30
I'll make up a #define to make life easier when porting.

If somebody wishes to try making some tests with a Hyper Terminal or alike connected... Smile

GENOVA :D :D ! GODO
#32
DarioG
Allmächtig.
  • Total Posts : 54081
  • Reward points : 0
  • Joined: 2006/02/25 08:58:22
  • Location: Oesterreich
  • Status: offline
RE: Minibasic for Pic32 2007/12/05 03:38:09 (permalink)
0
@Mike:
Created a project for PIC32 (my first one Smile) and made some changes to the C sources in order to be cross-platform.
It seems like it compiles correctly (see the new #defines) but... no MALLOC.H is there in PIC32! How can it be?

Ok, while we wait for some tip about Dynamic Memory allocation...
Here it is the project:
http://adpm.homeip.net/files/MiniBasic32.zip

(of course I also adapted the "18" version)

PS: oh, another problem: how do I do "char" signed by default? Looks like it is unsigned now... and I can't see the option in the Build Options Window... (I know, it should be one of GCC options... Smile)


GENOVA :D :D ! GODO
#33
DarioG
Allmächtig.
  • Total Posts : 54081
  • Reward points : 0
  • Joined: 2006/02/25 08:58:22
  • Location: Oesterreich
  • Status: offline
RE: Minibasic for Pic32 2007/12/05 08:52:56 (permalink)
0
ADDED: INKEY$ (INKEY as from Dan was something I did not like... I preferred the String version Smile) and SLEEP x, to generate some delay or put the PIC in Sleep mode.

GENOVA :D :D ! GODO
#34
Kiwi Mike AZ
Super Member
  • Total Posts : 2056
  • Reward points : 0
  • Status: offline
RE: Minibasic for Pic32 2007/12/05 15:42:46 (permalink)
0
FYI.

With C32: always defined is:   __PIC32MX
Include File is:                       p32xxxx.h

Include search path:          .....\C32\pic32mx\include\
Library Path:                     .....\C32\pic32mx\lib\


Some includes to use:

adc10.h
ports.h (int pins, pullups, int on change, I/O pin config etc)


It may be easier to create a seperate includes file that is generic to the project files.

Also means including processor specific files and processor specific defines can be made tidy.
Makes cross platform etc a little easier, and allows one code base.

e.g. "includes.h"  simply determines the compiler/processor used and then includes say...

    "inc_pic18.h"
    "inc_pic24.h"
    "inc_pic32.h"
 
Which have specific defines and includes needed for each different product range.
Of course locking of multipule entrys is recommended.

I can do this if you like.

Mike














#35
DarioG
Allmächtig.
  • Total Posts : 54081
  • Reward points : 0
  • Joined: 2006/02/25 08:58:22
  • Location: Oesterreich
  • Status: offline
RE: Minibasic for Pic32 2007/12/05 15:48:19 (permalink)
0
Thank you Mike.

Yes, if you feel like, do reorganize my MiniBasic32.zip code as said. We still have to find out that malloc() thing...

I've done some more enhancements to MiniBasic 18, and already published changes. I also changed the 32 version, you can work on it as is now. Obviously, I'm keeping the minibasic.c and h files all-the-same over 18F and 32.

I can work on the hardware side then, for example.

I've been playing with the real hardware today (18F2620), and it is fun Smile

GENOVA :D :D ! GODO
#36
Kiwi Mike AZ
Super Member
  • Total Posts : 2056
  • Reward points : 0
  • Status: offline
RE: Minibasic for Pic32 2007/12/05 16:09:05 (permalink)
0
Is your current copy on your website?

I am working on the Malloc issue - I have (hopefully) contacted an appropiate person about it, as I need it for a commercial application as well.


Mike
#37
DarioG
Allmächtig.
  • Total Posts : 54081
  • Reward points : 0
  • Joined: 2006/02/25 08:58:22
  • Location: Oesterreich
  • Status: offline
RE: Minibasic for Pic32 2007/12/05 16:14:32 (permalink)
0
Yes Smile brand new, I saw you had not gotten it yet, so I inserted some of the Macros you just told me , and the P32 include as well.
Still a lot to go of course.

I'm going to bed, you're welcome to download them both.

GENOVA :D :D ! GODO
#38
Kiwi Mike AZ
Super Member
  • Total Posts : 2056
  • Reward points : 0
  • Status: offline
RE: Minibasic for Pic32 2007/12/05 18:39:25 (permalink)
0
Hi Dario, Hope you had a good nights sleep..... while you were sleeping I have managed to do teh following....


1. malloc - Is in stdlib.h
2. Did a bit of work and now it compiles (with lots of warnings) for the PIC32
   Needs io/uart/interrupts etc to be completed - currently only for PIC18
   With Demo compiler - need optimization level 5 for C32 and Linker
   Also Set to 16bit mode for compiler and linker
   Compiled size FLASH 10900Words (~42KBytes)       SRAM ~6.7KBytes

Current ZIP will eventually be placed at:

http://www.pic32.org/minibasic/MiniBasic32.zip

Mike
#39
Kiwi Mike AZ
Super Member
  • Total Posts : 2056
  • Reward points : 0
  • Status: offline
RE: Minibasic for Pic32 2007/12/05 20:22:39 (permalink)
0
Did chunks of cpu.c, io.c and some iohw.c

Still need a good amount of work in those files - especially iohw.c

File now on website.

Mike
#40
Page: < 12345.. > >> Showing page 2 of 11
Jump to:
© 2020 APG vNext Commercial Version 4.5