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??
using SPI in swordfish
Moderators: Chuckt, Garth, bitfogav
-
- 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
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?
- brad
- 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
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.
-
- 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
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.
BUT it was suggested to go with the sHIFT.bas instead of SPI. WHY?? no clue but will give it a go.
Re: using SPI in swordfish
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:I need to store the bytes of data somewhere so I can input into the TLC5916 bit by bit
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:Going with the method of loading the bytes into a PORT would use 8 pins.
The TLC5916 is a SPI chip.MrDEB wrote: BUT it was suggested to go with the sHIFT.bas instead of SPI. WHY?? no clue but will give it a go.

If you don't know what Voltage your country is using, you shouldn't be doing electronics 

-
- 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
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()
Who is online
Users browsing this forum: No registered users and 4 guests