• 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.

Swordfish Thread

Status
Not open for further replies.

large_ghostman

Well-Known Member
Most Helpful Member
I keep derailing MrDebs thread (well as much as you can derail one of those), so i thought i would ask some stuff here. I have downloaded but not used SF yet, i need to read up how to get the ICD3 working with it first.

I will also be using the Junebug but I wanted that my Amandine and i was going to use the ICD3 for code.

First confession, I joined the SF forum and must be the only person to get the wrong answer to bah bah black sheep have you any____ no idea why but i put apples!! Lets just move on over that one, i havnt a clue why apples popped into my head.


If you do user modules, does this count as ram used (if you do indeed use some in a module?), I might port my SHT21 sensor code over from C, although I dont use these so much these days, they are pretty awful sensors with strange code needs, like voltage compensation!
 

Ian Rogers

User Extraordinaire
Forum Supporter
Most Helpful Member
If you do user modules, does this count as ram used
When the code compiles there is a "total" of Ram used... So yes! every bit of used ram is counted!

May I ask??? Is the reason for trying out Swordfish because you can't get your head around XC8?? I did notice you have run afoul of XC8.... If you had been using HTC as I have ( for years ) it was C18 that was the oddball..

Interrupts were VERY convoluted and memory allocation via a linker script?? Who the hell thought that one up.
Code:
XC8 ..
char ReallyBigArray[3000];

C18 ..
#pragma udata buffer_scn .. ( That I have formally allocated in the linker script )
static char buffer[3000];
#pragma udata
char * ReallyBigArray = &buffer[0];

XC8.. 
void high_priority interrupt ISR()

C18..
#pragma code InterruptVectorHigh = 0x08
void InterruptVectorHigh (void)
{
  _asm
    goto InterruptHandlerHigh //jump to interrupt routine
  _endasm
}
#pragma code
#pragma interrupt InterruptHandlerHigh
void InterruptHandlerHigh ()
   {
    //interrupt
   }
I know which one I prefer!!
 

large_ghostman

Well-Known Member
Most Helpful Member
Hi Ian, no my venture into swordfish is mostly because my soon to be 9 sis would like to learn to make pink leds flash (pink or purple actually), i started at 11 she is smarter :D, most my MC issues are to do with mplabx and some compatibility problems with the newer systems i have. That and having used other compilers for a while now. I am going to try the linux version of mplabx see how that goes. I had alot of C18 stuff written and it just dosnt seem to run under XC8, but it could be stupid things like my system wont run the switcher program for a start!

But SF is curiosity and the fact i think for her it would be easier.
 

granddad

Well-Known Member
Hi LG, good to see you encouraging sis with coding, I recommended Linux for MPLABX as all (well most ) of my 'WHAT the heck ' moments with it and win7 stopped , still use MPLABX on win for PIC24 XC16 does not seem to get as many annoyances, Basic is a good start , perhaps most have done something with it and it seems to have matured with its fans , I think ' walk before you run' is the best way, like flashing that first LED . I accept I am no programmer , I absolutely got bogged down with UNIX at work ( 20 years ago ! ) , but times change and you never stop learning . Sorry to hear about the tomatoes. I am just finishing a 10x15 foot poly so fingers crossed for a good growing season.
 

be80be

Well-Known Member
Linux and MPLAB X is the only way to go it just works no slow downs faster compile times It works.

I have Mplab x on a 4 core 64 bit windows box and my older shop computer is 2 cores AMD 4gbit ram and linux Ubuntu it works great it's way faster
Now I wish my C was way faster lol Im learning slow LOL
 

tumbleweed

Active Member
For comparison, here's what that xc8/C18 code would look like...
Code:
device = 18F4685

dim ReallyBigArray(3000) as byte

// interrupt priorities
public const
    ipLow = 1,
    ipHigh = 2

// high priority interrupt service routine
public interrupt InterruptHandlerHigh(ipHigh)
    // check IF and IE flags
end interrupt

// low priority interrupt service routine
public interrupt InterruptHandlerLow(ipLow)
    // check IF and IE flags
end interrupt

// zero the array
clear(ReallyBigArray)

enable(InterruptHandlerLow)
enable(InterruptHandlerHigh)
It won't compile with the free version because of the 256 byte ram limitation, and as you found out the SD card code uses 512-byte buffers so that's out, too.

Do you want to use the ICD3 just for programming or for source-level debugging?
 

be80be

Well-Known Member
I just remembered why I bought a copy now I was messing with SD and USB.
 

large_ghostman

Well-Known Member
Most Helpful Member
For comparison, here's what that xc8/C18 code would look like...
Code:
device = 18F4685

dim ReallyBigArray(3000) as byte

// interrupt priorities
public const
    ipLow = 1,
    ipHigh = 2

// high priority interrupt service routine
public interrupt InterruptHandlerHigh(ipHigh)
    // check IF and IE flags
end interrupt

// low priority interrupt service routine
public interrupt InterruptHandlerLow(ipLow)
    // check IF and IE flags
end interrupt

// zero the array
clear(ReallyBigArray)

enable(InterruptHandlerLow)
enable(InterruptHandlerHigh)
It won't compile with the free version because of the 256 byte ram limitation, and as you found out the SD card code uses 512-byte buffers so that's out, too.

Do you want to use the ICD3 just for programming or for source-level debugging?
I use the ICD3 for debugging in circuit. I am likely to use the junebug for my sister. The sd card thing isnt too big a deal, it was just something that was lined up and needing doing. If she gets on with basic then i will get th full one for her once we into season. At the moment its production time so everything is spend out, later on it switches around and we should start to see the benefits. One the downsides of a seven week lead time then a 28 day policy.

Actually i had totally forgotten the 512 byte blocks on the cards, i should have caught that one!
 

dr pepper

Well-Known Member
Most Helpful Member
I tried to get my apprentoid who's in his mid 20's into arduino and C, nope doesnt get it, now going to try ardublock, arduino for kids.
Your sis is doing well if she gets swordfish.
 

be80be

Well-Known Member
Swordfish is really a good IDE only drawback I seen is I wish it worked with 16f as well.
 

MrDEB

Well-Known Member
YES ON THE SF working on other pics but the 18F series is pretty good size and fairly cheap.
I suggest steering clear of the Junebug as it does have issues. After I went with a Pickit2 I solved some of my issues.
Good Luck
 

be80be

Well-Known Member
There's only one issue with the junebug maybe 2
One you set the jumpers wrong.
Two you put it together wrong.

One of the above is the only problems that you could have if you used good parts.
 

large_ghostman

Well-Known Member
Most Helpful Member
I joined the forum but waiting over a week now to be approved!!
I tried to get my apprentoid who's in his mid 20's into arduino and C, nope doesnt get it, now going to try ardublock, arduino for kids.
Your sis is doing well if she gets swordfish.

3V0 told me something way way back when i first started, i didnt understand it at the time but i get what he means now. With C its best to start with a simple compiler and a pc, understand the language and techni2que of C first. OR you better learn to read a data sheet.

He is correct, i did it the hard way and ended up having to9 understand pic datasheets before C made much sense. I think its mainly because when you do things like set up a chip etc, you need to understand that those random letters are registers that connect to different parts of the chip, you need to understand a pic is as stupid as brick until you make it smart. This takes time to learn that the oscillator needs setting up for internal/external, then the freq of it and so on.

With C on a pc you fire up a compiler and your kind of straight into it. Also the BIG mistake i think everyone makes is complexity, flashing a LED sounds boring and pointless but actually teaches you most of the fundamental aspects of how a pic works. Cut and paste is the other killer!

I am not great with C, dosnt help that i havnt used it for a little while, also dosnt help that i swap and change chip companies and compilers alot! But biggest tip i would give is, get some really well written and commented code to flash a led, one that comments the fuses and registers. Then TYPE it out, dont cut and paste but type it so you actually read and understand each line. hen move on to simple loops for the LEDS as above, and so on.

Arduino encourages the C&P plague, so much code around and stupid proof. I am kind of glad i started with pic way before arduino, the danger with Arduino is its too easy to get bad habits and lazy. My sister is smarter than i am, she has a womans ability to multi task and a memory like an elephant!! She just seems to be happy to learn to walk before she runs, i just want to get from A to B as fast as i can :D
 

dr pepper

Well-Known Member
Most Helpful Member
I'm reasonably Ok with C in embedded applications, I couldnt bring myself to programming a Pc.
I started with asm, so far back it was 6502 and Z80, then did a little bit of C in higher education, returning to it a few years back, glad I did.
The only issues I've had is converting data types and manipulating data bases.
Its good to know asm before a higher language.
The main reason I like arduino is that theres usually someone somewhere who's written a lib to do just what you want.
 

large_ghostman

Well-Known Member
Most Helpful Member
Arduino has its place, but personally i dont see it as a learning tool. Like you say someone has likely already done it for you, nothing wrong with that but depends which side of which fence you sit.

I like to write code and not just use libs, its my flavor of the hobby. Some just want to get the job done and arduino is perfect for that.

YES ON THE SF working on other pics but the 18F series is pretty good size and fairly cheap.
I suggest steering clear of the Junebug as it does have issues. After I went with a Pickit2 I solved some of my issues.
Good Luck
I have the original two junebugs from 8 years ago, they have seen alot of work. Never once have they had a problem, exceptional tool and dev board. Blueroom did an outstanding job with them and made the hobby possible for many many people.

Advising people to stay to stay away is pointless, it stopped being sold long ago. I had one and my dad had one, Blueroom soldered one and shipped it to us and 3V0 did the other. Funny how despite many many projects being done on them, and many mistakes being made like wiring bread boards up wrong, they have always worked perfect.

I think its likely the problem with yours is somewhere between the keyboard and back of the chair ;).
 

Pommie

Well-Known Member
Most Helpful Member
The biggest problem with Swordfish is the lack of debug facilities. You can integrate it into MPLAB and use debug via that but I didn't bother. I think you should reconsider using MPLAB with the XC8 compiler. Out of curiosity I downloaded some (XC8) servo code I posted on here and had it running on the junebug in less than 2 minutes. Unfortunately my Junebug then stopped working!!

Mike.
 

large_ghostman

Well-Known Member
Most Helpful Member
The biggest problem with Swordfish is the lack of debug facilities. You can integrate it into MPLAB and use debug via that but I didn't bother. I think you should reconsider using MPLAB with the XC8 compiler. Out of curiosity I downloaded some (XC8) servo code I posted on here and had it running on the junebug in less than 2 minutes. Unfortunately my Junebug then stopped working!!

Mike.
Can you get XC8 in MPLAB? Or did you use MPLABX? I will play with it later, debug is something i use alot, even if something works i like to have a nosy around new chip registers when the code runs.

I am aware of some servo code you posted a long time ago for the junebug, i have used that code so many times for different things. :D
 

JonSea

Well-Known Member
Most Helpful Member
MrDEB's Junebug problems mostly are understanding the jumper settings and trying to use it program other chips.
 

large_ghostman

Well-Known Member
Most Helpful Member
MrDEB's Junebug problems mostly are understanding the jumper settings and trying to use it program other chips.
I respectively disagree, they are most certainly between the keyboard and chair ;).

Actually i i am still in some shock having read his critique of your code, do me a favor......next time you want to help, please go slap yourself around the head until it passes.
I used MPLAB X with XC8. Don't think you can use it with the old IDE.

Mike.
So long since i used it, i thought there was a driver switcher, i am so used to simplicity studio or now and the Atolic. Funny thing is i got a unconnected job to do that would be ideal for a pic. I need to start on the bio reactor data logger and some stuff related to that. I wont be doing the full system until after the show season, trophy hunting this year to try and get some profile going.
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top