![]() |
![]() |
![]() |
|
|
|||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
|
|
Thread Tools | Display Modes |
|
|
(permalink) |
|
Hello guys,
I found this Swordfish Compiler and I would like to ask you guys, what Swordfish had as its advantage over another compiler like MCC18 C compiler or so? Thanks! Best regards, Kelvin Susanto
__________________
When NewBee asks... |
|
|
|
|
|
|
(permalink) |
|
That's probably subjective. It is (in my opinion) a very nice compiler though. I wish Microchip would pick it up and turn it into their official B18 language. They would make sure it functions within MPLAB and I think it might tend to legitimize a well designed BASIC language compiler as a 'professional' development tool.
Mike Last edited by Mike, K8LH; 30th May 2008 at 01:24 PM. |
|
|
|
|
|
|
(permalink) |
|
the thing i recon when I read thru tutorials from digital diy website is... u can just simplify the codes by writing several definitions and thats it. for example setting the pwm duty cycle or freq, a very nice tool but takes time to understand also. correct me if im wrong.
__________________
When NewBee asks... |
|
|
|
|
|
|
(permalink) |
|
I'm a little biased to comment - I'm sure other people will.
> They would make sure it functions within MPLAB... The current (BETA) version of the compiler has better MPLAB support, particularly with respect to debugging. http://www.sfcompiler.co.uk/wiki/upl...ebug/mplab.gif |
|
|
|
|
|
|
(permalink) |
|
I think Swordfish BASIC is hands down the best PIC BASIC compiler / IDE I've ever used. It's not a sloppy mess like MS BASIC.
|
|
|
|
|
|
|
(permalink) |
|
Forgive me if my "mplab integration" comment sounded like a complaint. I did read the recent post on the Swordfish forum regarding improved debug capabilities and it seems MPLAB integration is improving in small steps over time.
I was trying to say that Swordfish is the best BASIC compiler and IDE I've evaluated and tested. Full "mplab integration" is just another "wish list" item like having the ability to "offset" code and vectors from flash memory location 0x000. Mike |
|
|
|
|
|
|
(permalink) |
|
Until Swordfish supports debug I've simply used the UART.BAS module for viewing registers. It's old fashioned but it works.
|
|
|
|
|
|
|
(permalink) |
|
Swordfish produces an ASM file which can be used in MPLAB for simulation. I've done this a few times.
I'm going to have to check out the new debug capabilities. Mike Last edited by Mike, K8LH; 30th May 2008 at 11:02 PM. |
|
|
|
|
|
|
(permalink) | |
|
Quote:
The only other debug issue I run into is with interrupts, as they can be hard to calculate how much time you need to service the routine due to code overhead, but the best method I have found is to; a) Make a separate project to record how long it takes between pulses (rising edge trigger) b) On your target project, place a High(Signal.Pin) at the start of the interrupt, and a Low(Signal.Pin) at the end of the interrupt If your timer module is setup to display the maximum time taken as well as an average, then you have a very good idea on just how many cycles it has taken to service the interrupt. As for the modules/libraries within SF, well, its clean and very structured compared to some interpreted "top-down" PIC Basic compilers out there.
__________________
Spency. PIC Micro's - Your mind is the limit PIC's and interfacing with other devices - a PIC Basic Guide @ digital-diy.net |
||
|
|
|
|
|
(permalink) |
|
Hi Spency,
You could also just look at the ASM file and count cycles. I did this the other day with your RGB demo. The Save(0) and Restore commands are pretty costly, using approximately 140 cycles each. I seem to recall you were using somewhere around 23 usecs of the 50 usec interrupt interval which is almost 50% overhead. Regards, Mike |
|
|
|
|
|
|
(permalink) | |
|
Quote:
Say your program was doing the following (poor example, just for explanation); Code:
Interrupt TMR2_Interrupt()
...
mS = mS + 1
...
End Interrupt
.
.
.
...
While True
// Get a new ADC sample
Result = ADC.Read(0)
// Scale to volts, factor of 1000
Result = Result * 5000 / 1023
// Display on the LCD, always show 5 characters
LCD.WriteAt(1,1, Convert.DecToStr(Result, 5))
Wend
Now end uses can use the RGB program with any commands, and not worry about corrupting system registries. Yes there should be a more efficient way to go about this, eg, SF discovers what system registers are in use and only backs up the potential threats, but perhaps in a future edition... The program was originally written for Erosennin on my help forums as he also wanted to use the keypad routines to control the color components.
__________________
Spency. PIC Micro's - Your mind is the limit PIC's and interfacing with other devices - a PIC Basic Guide @ digital-diy.net |
||
|
|
|
|
|
(permalink) | |
|
Hi Spency,
Thank you for the explanation. I think I understand what the Save(0) and Restore commands do and when to use them. If you study the ASM code for your ISR in your RGB demo you'll see you don't need to use them in this case. I wasn't criticizing your code and it's perfectly ok to use the Save(0) and Restore commands since you have plenty of cycles to spare with a 48 MHz clock. I'm just not sure why you'd use them when you don't need to. Mike Quote:
Last edited by Mike, K8LH; 31st May 2008 at 01:04 AM. |
||
|
|
|
|
|
(permalink) |
|
No problems Mike,
This is probably a better example, pulled from the SF library Code:
// get value function... function GetValue(pValue as byte) as longword result = pValue * pValue * pValue end function // some interrupt... interrupt MyInt() dim Value as longword Value = GetValue(10) end interrupt
__________________
Spency. PIC Micro's - Your mind is the limit PIC's and interfacing with other devices - a PIC Basic Guide @ digital-diy.net Last edited by gramo; 31st May 2008 at 01:10 AM. |
|
|
|
|
|
|
(permalink) | |
|
Quote:
OMG! You really don't know that the WREG and STATUS registers are automatically saved when an interrupt occurs and then restored when the retfie FAST instruction is executed? Forgive me. I assumed too much. I thought you told me last year that you were an accomplished assembly language programmer before moving up to BASIC. This does however explain why some of your statements in the previous few posts (and some other statements this past year) seem so far "off base" to me. Mike Last edited by Mike, K8LH; 31st May 2008 at 01:21 AM. |
||
|
|
|
|
|
(permalink) | |
|
Quote:
had a look at the asm and a few things clicked which lead to the edit. Sorry if it was misleading, I just wanted to create a program that could be used no matter what the future use would be. I use context saving for safety sake with interrupts, and refine it off dependent on the application.
__________________
Spency. PIC Micro's - Your mind is the limit PIC's and interfacing with other devices - a PIC Basic Guide @ digital-diy.net Last edited by gramo; 31st May 2008 at 01:24 AM. |
||
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Latest |
| Swordfish SE Question | lclark | Micro Controllers | 11 | 2nd May 2008 03:06 PM |
| Unicorn + Swordfish + DS1820 | Pommie | Micro Controllers | 10 | 27th February 2008 10:34 PM |
| Swordfish DS1307 Example | gramo | Micro Controllers | 4 | 28th June 2007 11:48 AM |
| Swordfish - Structures | gramo | Micro Controllers | 0 | 10th May 2007 12:21 PM |
| Swordfish Example | gramo | Micro Controllers | 0 | 4th May 2007 02:09 PM |