using SPI in swordfish

Post here to let others know of a project you're working on.

Moderators: Chuckt, Garth, bitfogav

Post Reply [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
MrDEB
I practically live here!
I practically live here!
Posts: 372
Joined: Fri Feb 18, 2011 4:24 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

using SPI in swordfish

Post by MrDEB » Tue Nov 06, 2012 11:23 pm

Stll wondering if this is the way to go. I don't want to use too many pins to input serial data into a TLC5916.
I get the impression that using SPI I have to load a byte into say porta(utilizing 8 pins)
playing with a form of bit banging but??

MrDEB
I practically live here!
I practically live here!
Posts: 372
Joined: Fri Feb 18, 2011 4:24 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: using SPI in swordfish

Post by MrDEB » Wed Nov 07, 2012 1:35 am

Am I correct in assuming that I can load all my bytes into the EEprom instead of directly into ports then access the EEprom for my LED data via SPI?

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: using SPI in swordfish

Post by brad » Wed Nov 07, 2012 9:09 am

I could be wrong (I haven't used serial eeproms) but I have a feeling that you can store the data in the eeprom, then when you want it, you read it into the microcontroller and then forward the data onto the LED's.

MrDEB
I practically live here!
I practically live here!
Posts: 372
Joined: Fri Feb 18, 2011 4:24 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: using SPI in swordfish

Post by MrDEB » Wed Nov 07, 2012 10:50 pm

After reading I believe your right. I need to store the bytes of data somewhere so I can input into the TLC5916 bit by bit. Going with the method of loading the bytes into a PORT would use 8 pins.
BUT it was suggested to go with the sHIFT.bas instead of SPI. WHY?? no clue but will give it a go.

User avatar
bitfogav
Moderator
Moderator
Posts: 915
Joined: Sun Mar 28, 2010 9:03 pm
Location: United Kingdom
Contact:

Re: using SPI in swordfish

Post by bitfogav » Thu Nov 08, 2012 3:52 am

MrDEB wrote:I need to store the bytes of data somewhere so I can input into the TLC5916 bit by bit
Whats wrong in storing the bytes as a "Const" in programme code or even using the MCU eeprom to store the data?. not that I would use eeprom to store the data as it could slow down the access times needed to update the TLC5916.

MrDEB wrote:Going with the method of loading the bytes into a PORT would use 8 pins.
Why do you think that you need to use a PORT of 8pins to control the TLC5916?, if your using SPI then you will only need to connect 3 pins or 4 pins max from the MCU to the TLC5916.
MrDEB wrote: BUT it was suggested to go with the sHIFT.bas instead of SPI. WHY?? no clue but will give it a go.
The TLC5916 is a SPI chip. :roll: I know its not Swordfish but this link may help with the TLC5916 http://arduino.cc/forum/index.php?topic=65492.0
If you don't know what Voltage your country is using, you shouldn't be doing electronics ;-)

MrDEB
I practically live here!
I practically live here!
Posts: 372
Joined: Fri Feb 18, 2011 4:24 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: using SPI in swordfish

Post by MrDEB » Thu Nov 08, 2012 9:30 am

Good reading, just need to decipher the code BUT I might have what I need just have to test it out. Here is what I have using SHIFT.bas. Hopefully it will work Have questions about the INTERFACE as refereed to in the Swordfish reference library and the data pins . This code compiles correctly but does it work?? Will find out later as my wife is calling me to dinner.

Code: Select all

{
*****************************************************************************
*  Name    : UNTITLED.BAS                                                   *
*  Author  : [select VIEW...EDITOR OPTIONS]                                 *
*  Notice  : Copyright (c) 2012 [select VIEW...EDITOR OPTIONS]              *
*          : All Rights Reserved                                            *
*  Date    : 11/5/2012                                                      *
*  Version : 1.0                                                            *
*  Notes   :                                                                *
*          :                                                                *
*****************************************************************************
}
{
*****************************************************************************
*  Name    : UNTITLED.BAS                                                   *
*  Author  : [select VIEW...EDITOR OPTIONS]                                 *
*  Notice  : Copyright (c) 2012 [select VIEW...EDITOR OPTIONS]              *
*          : All Rights Reserved                                            *
*  Date    : 10/26/2012                                                     *
*  Version : 1.0                                                            *
*  Notes   : needs better definition of when pulse train is received                                                               *
*          :                                                                *
*****************************************************************************
}
 Device = 18F2420
Clock = 8
Config MCLRE = Off


'*********************************************************************
'Includes
//Include "InternalOscillator.bas"
Include "shift.bas"
Include "utils.bas"
Include "convert.bas"
Dim sdi As PORTC.6    // data
Dim clk As PORTC.7
Dim Latch_E As PORTB.0
Dim Out_E As  PORTC.3      // output enable
Dim row1 As PORTB.3       // HIGH  driver chip output

//Dim led_data As Byte
Dim sd_out As PORTC.6

Dim x As Byte
                 
 Const Red_Data(7) As Byte =   (%0010001, %00001010, %00000100 ,%00010001, %00001010,%00000100, %00010001)// 5 colums left to right
 Const R_ows(8) As Byte =      (%00000001, %00000010, %000000100 ,%00001000, %00010000, %00100000, %01000000,%00111110)// 7 rows top to bottom
 { as per timing diagram, clock outputs 8 pulses while output enable(Out_E) is held HIGH
 Latch enable(Latch_E) is held LOW. The data is shifted in one bit per clk pulse.
 }
   Sub load()    
       Out_E = 1               // output enable HIGH
       Shift.Out(LSB_FIRST, $ee,8)
       Out_E=0                 // output enable LOW
       DelayMS(1000)
   End Sub
   
   function get_data() as word
       Out_E = 1               // output enable HIGH
       Shift.Out(LSB_FIRST, red_data(1),8)
       Out_E=0                 // output enable LOW
   end function
 //  INTERFACE?? on Swordfish reference library  
   sub setinput(byref sdi as bit)
   end sub 
   sub setoutput(byref sdi as bit)
   end sub
   sub setclock(byref clk as bit)
   end sub         

   
  // start of program
  // set ports as outputs
TRISA = %00000000
TRISB = %00000000
TRISC = %00000000 
SetAllDigital 
shift.setinput(portc.6)
shift.setoutput(portc.6)
shift.setclock(portc.7)
output (portc.5)       //output enable
output (portb.0)       //latch enable
  load()  


   
      
     
  
     
     
     
    
      



Post Reply
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Who is online

Users browsing this forum: No registered users and 4 guests