Jump to content
Sign in to follow this  
jim

programming in Basic

Recommended Posts

Today I compiled X11-basic on pcDuino3 and thought that others might be interested. Many people got their start with the basic programming language. Next I plan to experiment with IO control, I2C, SPI, etc.


I followed these instructions and made adjustments as needed.


First install packages...


Code: [select]
sudo apt-get install libreadline-dev tcsh libncurses5-dev xutils-dev libc6-dev libsdl1.2-dev libtool

Download version 1.22 source file. I was not able to get the newest version, 1.23, to compile successfully. Maybe someone else will have better luck.

Download source files.


Extract files


Code: [select]
tar xvzf X11Basic-1.22.tar.gz

Change to the directory


Code: [select]
cd X11Basic-1.22

Make directory


Code: [select]
sudo mkdir -p /usr/local/share/man/man1

Configure, Make, and install


Code: [select]
./configure
Code: [select]
sudo make
Code: [select]
sudo make install
modify_inline.gif
 
 

 

Share this post


Link to post
Share on other sites

I also got FreeBasic working. It seems to have a better method for using external C libraries. If I can convert the c_environment headers and figure out how to use them then GPIO control should be easy. Perhaps it would just be easier to write my own IO drivers.

Share this post


Link to post
Share on other sites

I have achieved general IO control using X11 basic. Cycling a pin between high and low states using the least amount of code possible. Meaning not pretty code.  Running interpreted code I get about 8.5khz or 0.118ms. Compiled to native produces cycles at 12.0khz or 82.7us.


Edit: Arduino code produced 136.6khz or 7.32us


Seems like I have some work to do shocked.gif .

Share this post


Link to post
Share on other sites

Today I was able to use compiled C library in X11basic. I compiled the c_environment code to libarduino.so for use in x11basic.


Then I wrote this code to init gpio pins, set pinmode of pin 1 to output, and then raise and lower pin 1 with as little code as possible.

'Run init
link #1,"./c_environment/libarduino.so"
adr=SYM_ADR(#1,"init")
ret=call(adr)
'Set pinmode to output
adr=SYM_ADR(#1,"pinMode")
ret=call(adr,1,1)
' setup digitalWrite
adr=SYM_ADR(#1,"digitalWrite")
do
ret=call(adr,1,1)
ret=call(adr,1,0)
loop
unlink #1

Running this code from the interpreter produced switching as 17.4khz or 57.2us.
Compiled to a native program produced 41.2khz or 24.3us.


This matches what I was able to do with yaBasic and since it does not have the ability to access C libraries I do not see a way to improve it.


Using the compiled library should also give me access to SPI, I2C, etc. Time will tell.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×