Free Alternative to PicBasic?

Free Alternative to PicBasic?

I'm looking for a freeware high level language for programming microcontrollers.

I currently use an old version of PicBasic Pro to write code for hobby projects; mostly on 16F877A.

I'd like to experiment with newer PIC devices not supported by my old version. Also like to try some of the AVR parts. Retargetable for different vendor products is very helpful. Time to start looking for alternatives.

The BASIC language is sufficient for my needs, and I already know it. But I'd be open to another language. I don't have any problems with the C language per se, but I always get lost in the libraries and setup functions...and what the heck is a pragma??? ;-) The C code to do what I want is pretty simple. All the stuff around it to make it compile is something I've not figured out.

I'm kinda dyslexic. Low level languages are a real pain when you can't get the ones and zeros in the right order.

PicBasic has a lot of nice features for the simple minded like me. It has built-in functions for common tasks, like RS-232, timing, LCD output, inline assembler, etc. And the compiler does the math. IF I input the clock speed and the RS-232 speed, the compiler does the math and I don't have to figure out which is the baud-rate register and what to plug into it. Since the compiler library is written in assembly that I can modify, I have hacked the compiler to add functionality. Way cool... I'd like not to give up that kind of library capability.

I research this periodically and always give up. There are "trial versions" of C compilers that have significant limitations, like very limited processor support or limited code size. There's SIGNIFICANT learning curve for a new toolset. I'm not gonna waste the time on something that won't let me use the full capability of the processors. I can already do that.

There are open source tools for linux that look promising on the surface, but much of the information available on the web is several years old. Lots of pieces, but the tutorials come from different sources with different objectives. Tab "A" doesn't seem to go into slot "B" when I attempt to figure out how to get C into the IDE on one end and hex out the other. Is there an actual package that does the job end to end? Or at least a tutorial on how to set it up with current tools with compatible interfaces.

This is a hobby. I've got time to waste learning stuff. That's the definition of hobby. I don't have money to spend buying stuff. The budget really is ZERO. If I want to spend money, I'll get a girlfriend. ROI is much better.

I'd like to hear about a freeware toolset that someone has actually put together and used.

Hearing about something your brother told you he might have seen on youtube probably won't be helpful.

Telling me to google for it won't help unless you provide keywords I may not have tried.

Thanks

Reply to
mike
Loading thread data ...

Free HLL compilers for the PIC are, unfortunately, in short supply.

I am currently using JalV2 with its companion library, JalLib. It supports up to and including PIC18.

Jal does not support AVR, but I think there are free C compilers available for AVR.

Jal and JalLib can do all of that.

Both the compiler and the libraries are open source, so you can modify all you like.

Here are a few links to help you gather more information:

The JalV2 compiler:

formatting link

The JalLib libraries:

formatting link

The Jal Yahoo mailing list:

formatting link

A page with lots of useful stuff:

formatting link

There are several editors/IDEs specialized for Jal, such as JalEdit, Picshell, Jalcc to mention a few.

--
RoRo
Reply to
Robert Roland

If you must have free, and consider C an HLL, then maybe SDCC. The generated code is not terrific, though it seems workable.

Mel.

Reply to
Mel

... bunch of PIC related comments deleted

If you are interested in the AVR look at the Arduino project.

formatting link

The base is an easy to use subset of C (C++ actually)called a sketch. It includes a lot of predefined functions for on chip peripherals and things like character LCD modules. Hosted on Windows, Linux and MAC. I use it with Windows and Linux - I don't have a MAC.

The sketch code is run through a preprocessor to get C code and then through gcc and the linker. All the tool chain preprocess, compile, library and link stuff is hidden in simple use. If you need more than is provided in the base you can add your own your own code and libraries to the tool chain.

I have pretty much moved over to this from PICs.

Reply to
Dennis

I have two recommendations:

  1. The .00 upgrade for melabs PBP is well worth it. (ROI for time not spent is priceless.)
  2. Microchip C compilers are very high quality.

TomC

Reply to
tomcee

Another vote for the Arduino; it's what I recommend nowadays to folks who want to give embedded programming a try.

An alternative would be the Parallax family of BASIC Stamp modules

formatting link

--
Rich Webb     Norfolk, VA
Reply to
Rich Webb

Go get the latest MPLAB IDE from MicroChip. They have wrapped a lot of the low level handling in some libraries. The c compiler is free but after 60 days you cannot use some of the advanced optimizations. Probably for what you want to do that is a "dont care" - so the compiler remains free. I use the IDE with my old PicStart programmer with no problems.

--
Joe Chisolm
Marble Falls, Tx.
Reply to
Joe Chisolm

I'm working with MPLAB on some PIC projects, and I don't find their library code all that easy to use. Some parts are very poorly documented. On a few occasions I had to go look at their library source code to figure out how things were supposed to be used.

Reading the device data sheets, and writing directly to the peripheral registers was easier in some cases.

Reply to
Arlet Ottens

Pic C-lite / C18. Lots of examples available. Free as well.

I've travelled the exact same path as yourself - assembler / basic ---> C.

(another) Dennis.

Reply to
Dennis

Can I suggest a different approach -- and perhaps get you some exposure to the other side (dark? side) of the coin?

Find a copy of the "BASIC 52" interpreter Intel used decades ago in their masked 8052AH-BASIC part. This is written in 8052 assembler. You can study how the interpreter works and then *translate* it to the processor of your choice.

This gives you exposure to a different class of processor (8048/52), assembly language (on *two* processors) *and* a "BASIC" that you can use on your ultimate target AS WELL AS the knowledge of what's under the hood (so you could modify it to add features that you might want).

Yes, I know this isn't the path you described setting down. But, it is an alternative that you might find interesting.

Something new to try for the coming New Year...

Reply to
D Yuniskis

I guess you've won the prize for the most difficult solution for his problem :-)

I doubt Mike can do it, if he has already problems using C, e.g. installing MPLAB and using an example from the free HI-TECH C compiler as the base for his programs and reading the datasheet for calculating the values for the baud rate registers instead of using some program magic for it. The only limitation of the HI-TECH C compiler is that the code is not as optimized as in the commercial version. It's really not that difficult, see e.g. this simple project:

formatting link

Or this preview of my latest project, a speed and time measurement device with 200 us resolution (with a PIC18F252)

formatting link

The full source code and schematic is attached to the German article, which are linked in the description of the video. It is one C file with 415 lines, including 50 lines for the 16x16 bitmap font. No libraries are used, except the standard C libraries for sprintf and floating point handling (yes, it is slow on the PIC and uses lots of flash, but it is no problem, as the PIC18F252 has lots of flash and the calculations are outside the interrupt).

You can't do projects with 200 us resolution with a BASIC interpreter. But you could do it with a BASIC compiler. But this is more difficult than writing an interpreter. You could start with writing a parser:

formatting link

You can write the parser in BASIC, too. It is no problem to write a BASIC parser in BASIC. But try it with something on and for the PC, e.g. Visual Basic from .NET inside the free Visual Studio, because it is easier to test and debug. Then you can try to enhance it to a parser and finally to a compiler.

And buy the dragon book, if you want to learn how to write compilers, because it is the standard book for this kind of stuff and helps you not reinventing the wheel:

formatting link

Much better for learning compiler design than reading an assembler implementation of a BASIC interpreter :-)

--
Frank Buss, http://www.frank-buss.de
piano and more: http://www.youtube.com/user/frankbuss
Reply to
Frank Buss

I guess it depends on your view of his "problem". I saw it as "BASIC is a good fit for me. But, I'd like to learn more. Am willing to spend time (not money). And want to move on to another processor."

In that light, my idea has merit as:

- reading through the source, he can *see* the BASIC statements that cause the various parts of the interpreter to be invoked

- he can see "working code" that *implements* those various things

- he gets exposed to another processor (albeit not the one he mentioned in his post -- at least not *immediately*)

- he gets to learn something (assembly language) while someone has already come up with the overall solution/structure

Ah, but the value of digging into the bowels of the mentioned interpreter is that you can write your own low level routines that do the dirty work while the mechanisms for communicating between "BASIC" and your routines is already spelled out for you (i.e., look at how the other hardware related BASIC extensions in the interpreter work).

I wrote a "multitasking BASIC" interpreter that ran on the 647180 that would interface with low level routines ("drivers", if you will) to do all the time critical stuff and used it for quick turnaround "proof of concept" demos for customers (before single chip MCU's were as commonplace as they are today). Never "fast enough for a real product" but REALLY easy for a customer to see what sorts of things *could* be done along the lines of his "inquiry".

The 8052AH-BASIC's parser is an ad hoc implementation. Crude but effective. Remember, the code is *small*. Being an interpreter has the advantage that you don't need a "toolkit". Set up a terminal emulator and talk to the target device itself.

In ASCII.

No editors, linkers, librarians, etc.

If you "doubt Mike can do it", I suspect trying to get him to read a text on compiler design is going to be a good fit! My first class on compiler design predated Aho/Ullman's first Dragon book (there was a similar second text some ten years later). No doubt, the text *we* used (Gries) was a tougher read :< (typeset in Courier and no pictures -- other than ASCII art! :> )

I don't think I implied that he would "learn compiler design" in the process. Rather, that he would learn how something he has been using (BASIC) works "under the hood" (i.e., maps onto real hardware). Compilers often obfuscate what your code is trying to do with optimizations, atypical usages of instructions and addressing modes, etc. OTOH, an interpreter usually does *exactly* what you tell it ("you want to add 0 to 0? OK...) -- no optimizations, etc.

Reply to
D Yuniskis

.... =A0Also like to try some of the AVR parts.

I googled some words you probably did not try ;)

[antti AVR Basic]

and got this

formatting link

links to this

formatting link
ource

Says the sources DO compile with either Delphi or FreePascalCompiler from here

formatting link

So, it is Basic, (compiling) for the AVR, and it is open source.

-jg

Reply to
malcolm

For an example on pic16+sdcc you can take a look at my code I wrote a while ago. I'm no expert, but the setup works for me. Feel free to email me with any questions.

formatting link

-- Trygve

Reply to
Trygve Laugstøl

Yes, although the free versions suck bigtime on speed and code size

Reply to
Mike Harrison

tomcee wrote: snip

First thing I tried. nocando bought it used, so not eligible for upgrade.

Reply to
mike

Have no need for an interpreter. Actually got one for the 16F877. Works, but slow as... Don't think it runs on the 877A 'cause it tries to write a word at a time and trashes three words in the process.

Any compiler with an assembled output will let you examine what's under the hood. My objective is to stay out from under the hood as much as possible.

Yep, that's a little too far off the beaten path. I did write the code for my ham radio repeater/remote base/phonepatch in assembler for the RUPI variant of the 8051..or maybe it was an 8048 variant...was a LONG time ago. Couldn't afford to buy a uP, so got RUPI's out of old computer keyboards. I remember my excitement when I got my first UV eraser at home. ;-) Also remember the look on my boss' face when I put in a requisition for a hundred 64Kbit EPROMS at $250 each. Good times...

MPLAB has been installed for years. Used it to run the picstart+ until bootloaders became popular and Microchip started giving away samples that could be bootloaded.

I tried to use the simulator, but everything I do is real-time and/or interrupt driven. Simulator wasn't too useful to me.

and using an example from the free HI-TECH C compiler as the base for

Reading the datasheet is not HARD. It's a matter of having to remember to recalculate it all again every time you change clock rate or baud rate. IT's really handy to have the compiler fix it. I'm dyslexic, you know.... The only

Optimization is not critical for me. I try to do all the user interface stuff on a palm pilot, the hardware stuff on the PIC in BASIC with inline assembler where I need speed or predictability. Still have a lifetime supply of PAL20V8's for the really fast stuff ;-) Yes, I do live two decades in the past. It's much cheaper...nearly free... here. Is there a computer mnemonic like NAN for free? How about NA$ ?

One thing I'd like to get out from under is the darn paged memory in the PIC. I'm always tripping over page boundaries when I try to cheat the compiler. Spent half a day fretting over why two BASIC instructions wouldn't work when translated to two assembler instructions. Whodathunk they'd put the TRIS register and PORT register in different memory pages. I'm gonna have RTFM tattooed backwards on my forehead so I can read it in the mirror.

Just took another look at HI-TECH C. The bootloader incompatibility is a problem for the trial version. Shouldn't be a problem for the tiny bootloader if they didn't put anything in address 3. I had it in my head that they had severe limitations in chip support and code size for the expired trial.

Your setup isn't too different from mine. I use an old Heathkit breadboard with RS232, keyboard and lcd cobbled onto it. I took the easy way out and use a BT-serial converter for wireless connection to the Palm. Also built a PIC GPIB to serial converter so I can do instrument control. But I'm afraid to use it. I fast charge batteries. All I need is for the bluetooth to lock up and explode something. My code is not fault-tolerant...yet.

snip I seem to have come off as incompetent. I did try to ask simple questions. I claim to be competent, just lazy and CHEAP!!! I tend to use whatever I've got and make it work.

So far, the most interesting thing I've found is Great Cow Basic. Looks much like PicBasic, except it's free. Can't find any mention of inline assembler. Gonna need that for interrupt handlers and some optimizations.

I spent much of the day reading about Arduino. That looks interesting too. I haven't convinced myself to spend the $20 to buy one, but I might come around.

Also dug thru the junkbox and found a TI MSP430 eZ430-RF2500 wireless prototype kit. Also, somewhere I have the previous version without the RF. As I recall, the prototype boards with the processor were 3 for $10. That's more my speed ;-) Never did anything other than run the wireless demo. Ran into the same (lack of) compiler issues. What are your thoughts on TI chips?

Reply to
mike

No, since Microchip aquired HI-TECH software, they are only limited for optimization: The paid versions produces smaller and faster code.

TI chips are nice. I've tested the LaunchPad:

formatting link

(sorry, the article is in German, but you could try Google translator)

But the more powerful chip from TI are more expensive than the PIC chips. But maybe doesn't matter much for hobby projects.

C is not that difficult. Once you can program in C, you have many more possibilities than with BASIC and most of the time you don't need any more inline assembler.

--
Frank Buss, http://www.frank-buss.de
piano and more: http://www.youtube.com/user/frankbuss
Reply to
Frank Buss

If you want to spend more time then money and already have a breadboard and a junk box (which I think you do) you can get just the chip with preprogrammed boot loader for about $6.

Search on the terms Arduino + breadboard to find examples. A lot of them try to do the whole thing and use a USB to serial converter as part of their project. If you already do ttl level serial (likely from your PIC work) you can skip that part.

the .net Dennis

Reply to
Dennis

Interesting. Would be nice to see the assembly code it spit out. I don't do anything near that complicated. I normally want all the speed I can get. If I wanted the answer tomorrow, I'd wait until tomorrow before I started writing the code. ;-)

Looking at the code reminds me of an early foray into C. I had a quickbasic program running on a 286 PC. Decided to port it to TurboC. I took all the spaghetti code with random variables, put related variables into structures and passed the structures to subroutines. I was so proud of myself. Then I tried to run it. It was so slow that it didn't do the function I needed. I had to copy the variables out of the structures, work on them, then put them back into the structures. Ran plenty fast that way. I was very disappointed in my inability to make all the cool structured features of C do the job.

Reply to
mike

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.