Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

convertinf Ardunio code to Swordfish basic

Status
Not open for further replies.
Well after redoing, downloading, extracting all required files and saved in different location as per Tumblweeds suggestion
HUSTON WE HAVE LANDED
It now compiles and actually works!
Thanks all that helped. My grandson will love this "toy"
Need to eliminate several tunes in the example as per wife's wishes.
 
Great work Ian.

For anyone playing at home, if you want to try it using the free Swordfish SE compiler and the 18F43K22,
you can change the chip in the xxxx_example.bas programs....

rtttl_example.bas:
Code:
program RTTTL_example

device = 18F43K22               // <<<<<< CHANGED TO COMPILE FOR 18F43K22
clock = 64

// int osc and IO pin libraries
include "intosc.bas"
#option DIGITALIO_INIT = true       // automatically call setalldigital
#option DIGITALIO_SLEWRATE = 1      // 1=slow (we don't need fast edges)
include "setdigitalio.bas"

// tone library
// specify output pin
#option TONE_OUTPUT_PIN = PORTD.7       // <<<<< 18F43K22 PORTD OUTPUT PIN
include "tone.bas"

If you try to compile the tone_example.bas, you'll have to change one declaration so it'll fit the SE version RAM limit of 256 bytes...
About half-way down the page in tone_example.bas, change the note_list array size
Code:
// note list in ram (freq, duration pairs)
dim note_list(32*2) as word                         // <<<<<< change for SE version

main:
 
The Swordfish "Special Edition" is the free version of Swordfish Basic. It's extremely generous in its limitations to the point that many users never upgrade to the paid version (perhaps a bit too generous!).

If you've ever used Visual Basic, Swordfish will be very familiar. Don't take MrDEB's trials and tribulations as a reflection on the language. I find Swordfish easy to use and it compiles fast, efficient code.
 
Yes, the free SE version supports the entire 18F series of devices, including the newer Q family like the Q10, Q43, Q83/84, and the 16/20 pin Q40/Q41.

The only limit is RAM... only 256 bytes available (you're limited to bank0).
It even supports vectored interrupts.
 
I found I had to change the 18f23k22 to 18f43k22 to be able to compile.
Am using the paid version of SF.
And yes to what Visitor said.
now to edit the code to turn on LEDS per notes of melody and put the auto turn off to monitor portB.
 
Nice... But I use C and I have a licensed version of XC8 so I would never buy a copy..

I just wanted to see why MrDeb had all them issues..
Funny how you got it to work in one post and we're 4 pages in...
Think you've got it figured out as to why?


I found I had to change the 18f23k22 to 18f43k22 to be able to compile.
Gee, so the example wasn't written specifically for your board? Go figure.

now to edit the code to turn on LEDS per notes of melody and put the auto turn off to monitor portB.
Last mentioned, your board has 8 LEDs and 8 switches.

Do you want to use the switches to play songs using the RTTTL player, or just use the tone module to play a different note (and LED) for each switch press? Or something else?

If you're using the RTTTL player you can get the name of the tune using rtttl.get_name() and put it on the LCD.
 
Funny how you got it to work in one post and we're 4 pages in...
Think you've got it figured out as to why?
Dont get me wrong.... I have no issues helping MrDeb, and I know making stuff sink in take a bit of time, but is what it is..

I had to get the compiler so I check what working or not..
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top