I am trying to learn Swordfish, one of the issues to test before I buy a full version is how to use SPI with Swordfish; but I can´t find information about 25640 in SF help, is it because I only have Swordfish SE ?, or am I looking in the wrong place?
In the web page in the Modules area, I can find mention of SPI devices, but I can´t find any other information.
If I buy a full version of Swordfish, Will I get more documentation than what is in the help?
SPI25640
Moderators: David Barker, Jerry Messina
-
- Posts: 9
- Joined: Thu Jul 03, 2008 4:09 pm
- Location: Cambridge, Canada
25640.bas
I guess I would look at the samples more carefully to learn from them, but the samples are very limited in that they cover only a few options. 25640.bas is a module included in the sample program for SPI in the samples folder of SF.
here it is:
// if device and clock are omitted, then the compiler defaults to
// 18F452 @ 20MHz - they are just used here for clarity...
Device = 18F452
Clock = 20
#option LCD_DATA = PORTD.4
#option LCD_RS = PORTE.0
#option LCD_EN = PORTE.1
#option SPI25640_SOFTWARE = true
Include "25640.bas"
Include "LCD.bas"
Include "convert.bas"
Dim Array(10) As Byte
Dim Index As Byte
Dim Str As String
ADCON1 = $07 // PORTE as digital (LCD)
Cls
Initialize
SetCS(PORTC.1)
If Available Then
LCD.WriteAt(2,1, "AVAILABLE")
For Index = 0 To Bound(Array)
Array(Index) = (Index + 1) * 3
Next
spi25640.Write(0,Array,"FINISHED ")
spi25640.Read(0,Array,Str)
For Index = 0 To Bound(Array)
LCD.WriteAt(1,1, DecToStr(Array(Index)))
DelayMS(500)
Next
LCD.WriteAt(2,1, Str)
EndIf
here it is:
// if device and clock are omitted, then the compiler defaults to
// 18F452 @ 20MHz - they are just used here for clarity...
Device = 18F452
Clock = 20
#option LCD_DATA = PORTD.4
#option LCD_RS = PORTE.0
#option LCD_EN = PORTE.1
#option SPI25640_SOFTWARE = true
Include "25640.bas"
Include "LCD.bas"
Include "convert.bas"
Dim Array(10) As Byte
Dim Index As Byte
Dim Str As String
ADCON1 = $07 // PORTE as digital (LCD)
Cls
Initialize
SetCS(PORTC.1)
If Available Then
LCD.WriteAt(2,1, "AVAILABLE")
For Index = 0 To Bound(Array)
Array(Index) = (Index + 1) * 3
Next
spi25640.Write(0,Array,"FINISHED ")
spi25640.Read(0,Array,Str)
For Index = 0 To Bound(Array)
LCD.WriteAt(1,1, DecToStr(Array(Index)))
DelayMS(500)
Next
LCD.WriteAt(2,1, Str)
EndIf
-
- Posts: 9
- Joined: Thu Jul 03, 2008 4:09 pm
- Location: Cambridge, Canada
Tim, I mean just that. I find the samples are good in many cases, but some times it is difficult to write ones own code based on samples that do not cover the use of available options in modules. Since SF is modular and this modules can be accessed from ones code, sometimes when there are errors in the use of options and or variables of a module, the compiler generates an error message that points to a line in an existing module. I know these error messages are caused by errors in my code, not in the module itself (this happened to me, but do not worry about the specific instance, it surely was caused by my own ignorance).
The difficulty lies in learning by sample, some times it is much better to learn by understanding the rules, the syntax, the basic grammar of the language, and the structure and then look at the samples. I find the user guide very well done, but I do not think the same of the information about the modules in the help, since SF grows with the modules (by the way, this is great) then the modules become an integral and necessary part of SF; If I do not know how to use (deeply) the modules, then I can not use the most powerful part of SF.
In any case the SPI difficulty I have may be solved by looking at some code I found in the WIKI, 24LC640.
Thanks for your help Tim.
The difficulty lies in learning by sample, some times it is much better to learn by understanding the rules, the syntax, the basic grammar of the language, and the structure and then look at the samples. I find the user guide very well done, but I do not think the same of the information about the modules in the help, since SF grows with the modules (by the way, this is great) then the modules become an integral and necessary part of SF; If I do not know how to use (deeply) the modules, then I can not use the most powerful part of SF.
In any case the SPI difficulty I have may be solved by looking at some code I found in the WIKI, 24LC640.
Thanks for your help Tim.