Go Down

Topic: help with how to connect tlc5940 to atmega1284p (microduino core+) (Read 6222 times) previous topic - next topic

account001

i am very sorry we don't understand each other.i have looked at the pin layout and i know that atmega1284p has the MOSI, MISO, SCLK pin, and i know the MISO is not need for the tlc5940, the MOSI connects to the SIN pin of the tlc5940 and the SCK pin connects to the TLC5940's SCLK pin. what i am confused about is the SS pin of the atmega1284(which you said is a redefinable pin), is there a pin on the tlc5940 chip that i have to connect the SS pin of the 1284p to? if not, how does it work?
For the atmega1284 i am only unsure of the which timer pins to use, for the tlc5940 i am no sure on where the SS pin is.
please tell me if my concept of the use of the SS pin is wrong, thanks.

i do indeed read and remember all your post i assure you. Even though you sound really fustrated, i really Thank You for you help.

account001

Please forgive me but right now i am doing my last year in high school and preparing fo the uni exam, so i have very little time to do reaserch, and i figure asking other for help would be easier. That is why i am askin gall these perhaps stupid questions. i hope you understand.

raschemmel

#17
Mar 27, 2014, 07:13 am Last Edit: Mar 27, 2014, 07:21 am by raschemmel Reason: 1
Quote
I have already told you which pins a SPI device requires but you have not asked me which pins on a 1284 correspond to the pins you need to use the TLC5940. You have not posted the datasheet for the 1284 so how do you know how to connect it to a 1284? Did you find a schematic somewhere showing how to connect the TLC5940 to a 1284 ?  


I specifically asked this question to find out if you had taken the time to install the Library and look at it. If you had done that you would discover the folder named "Pinouts"

Quote
The MOSI, SCLK and default SS pin on the atmega1284p seems pretty clear on the atmega1284p's datasheet, i am more unsure on what timer pins to use.  

When I read this I knew you had not installed the Library or looked at it.
Remember when you said this (back in Reply#4) ?
Quote
thanks for the reply, i looked at the tlc5940 ibrary and it seems to have atmegaxx4.h which i think   includes 1284p, so i will look into that,  


We are on Reply#17 now.
Is it possible that maybe that is why I sounded frustrated ?

Quote
what i am confused about is the SS pin of the atmega1284


Look at pin 5 of the 1284 pinout. It is labeled "SS". That is the pin you use for the SS pin. (redefinable simply means you could change it to some other pin if you wanted to).  
Did you install the TLC5940 Library ?
If you install it and look in the library folder, you will see a subdirectory named "Pinouts"
If you look in that subdirectory you will see all the pinout files for different Atmel processors.
One of them is named "ATmega_xx4.h".
If you had installed the Library you would have found this folder.
This is the contents of the file I am talking about that is installed with the library.
Code: [Select]
/*  Copyright (c) 2009 by Alex Leone <acleone ~AT~ gmail.com>

   This file is part of the Arduino TLC5940 Library.

   The Arduino TLC5940 Library is free software: you can redistribute it
   and/or modify it under the terms of the GNU General Public License as
   published by the Free Software Foundation, either version 3 of the
   License, or (at your option) any later version.

   The Arduino TLC5940 Library is distributed in the hope that it will be
   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with The Arduino TLC5940 Library.  If not, see
   <http://www.gnu.org/licenses/>. */

#ifndef TLC_ATMEGA_XX8_H
#define TLC_ATMEGA_XX8_H

/** \file
   SPI and timer pins for the ATmega164/324/644.  Don't edit these.  All
   changeable pins are defined in tlc_config.h */

/** VPRG (Sanguino digital pin 15) -> VPRG (TLC pin 27) */
#define DEFAULT_VPRG_PIN    PD7
#define DEFAULT_VPRG_PORT   PORTD
#define DEFAULT_VPRG_DDR    DDRD

/** XERR (Sanguino digital pin 6) -> XERR (TLC pin 16) */
#define DEFAULT_XERR_PIN    PB6
#define DEFAULT_XERR_PORT   PORTB
#define DEFAULT_XERR_DDR    DDRB
#define DEFAULT_XERR_PINS   PINB

/** SIN (Sanguino digital pin 5) -> SIN (TLC pin 26) */
#define DEFAULT_BB_SIN_PIN      PB5
#define DEFAULT_BB_SIN_PORT     PORTB
#define DEFAULT_BB_SIN_DDR      DDRB
/** SCLK (Sanguino digital pin 7) -> SCLK (TLC pin 25) */
#define DEFAULT_BB_SCLK_PIN     PB7
#define DEFAULT_BB_SCLK_PORT    PORTB
#define DEFAULT_BB_SCLK_DDR     DDRB

/** MOSI (Sanguino digital pin 5) -> SIN (TLC pin 26) */
#define TLC_MOSI_PIN     PB5
#define TLC_MOSI_PORT    PORTB
#define TLC_MOSI_DDR     DDRB

/** SCK (Sanguino digital pin 7) -> SCLK (TLC pin 25) */
#define TLC_SCK_PIN      PB7
#define TLC_SCK_PORT     PORTB
#define TLC_SCK_DDR      DDRB

/** SS will be set to output as to not interfere with SPI master operation.
   If you have changed the pin-outs and the library doesn't seem to work
   or works intermittently, make sure this pin is set correctly.  This pin
   will not be used by the library other than setting its direction to
   output. */
#define TLC_SS_PIN       PB4
#define TLC_SS_DDR       DDRB

/** OC1A (Sanguino digital pin 13) -> XLAT (TLC pin 24) */
#define XLAT_PIN     PD5
#define XLAT_PORT    PORTD
#define XLAT_DDR     DDRD

/** OC1B (Sanguino digital pin 12) -> BLANK (TLC pin 23) */
#define BLANK_PIN    PD4
#define BLANK_PORT   PORTD
#define BLANK_DDR    DDRD

/** OC2B (Sanguino digital pin 14) -> GSCLK (TLC pin 18) */
#define GSCLK_PIN    PD6
#define GSCLK_PORT   PORTD
#define GSCLK_DDR    DDRD

#endif

 

As you can see , the SS pin is clearly defined as :
Code: [Select]
#define TLC_SS_PIN       PB4  
PIN PB4 is physical pin #5
The GSCLK pin is PD6.
Code: [Select]
#define GSCLK_PIN    PD6
pin PD6  is physical pin #20
BLANK is pin PD4
Code: [Select]
#define BLANK_PIN    PD4  
PIN PD4 is physical pin #18

If you look closely at the pin names on the 1284 pinout image I attached , you will see that the timers you asked about when you said this:

Quote
The MOSI, SCLK and default SS pin on the atmega1284p seems pretty clear on the atmega1284p's datasheet, i am more unsure on what timer pins to use.  


are the pins I just mentioned above.
All of the TLC5940 signals are assigned 1284 pins in this file. It is a  *.h header file so you can't open it with the IDE but you can open it with Word and save it as a .txt file for later.
All the other pins are SPI pins and you already know which ones those are.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

account001

Thanks again. I have not install the library file instead I have looked at it using word wrap. What happened is I didn'tfind 1284p in the xx4.h file,instead  there is the 644,which at that time I was mot sure it has the same pin layout as the1284.  also the file named chip included.h did not have 1284 in it. But now it seems you think it is compatible so I will go with that.Trust me I did go and look at the file. Which is why I am confused, I thought there would be a pin on the TLC5940 that you connect the ss pin and it didn't say in the library file where on the TLC5940 it is. but it seems once again I am wrong. Am I correct in saying this? So I just need to have ss pin defined in the library but I don't actually hook it up with the. TLC5940 right? You have been of most help to me thanks alot.

raschemmel

#19
Mar 27, 2014, 02:59 pm Last Edit: Mar 27, 2014, 07:30 pm by raschemmel Reason: 1
Quote
Trust me I did go and look at the file. Which is why I am confused, I thought there would be a pin on the TLC5940 that you connect the ss pin and it didn't say in the library file where on the TLC5940 it is.



Quote
what i am confused about is the SS pin of the atmega1284

Look at pin 5 of the 1284 pinout. It is labeled "SS". That is the pin you use for the SS pin. (redefinable simply means you could change it to some other pin if you wanted to).  
Did you install the TLC5940 Library ?
If you install it and look in the library folder, you will see a subdirectory named "Pinouts"
If you look in that subdirectory you will see all the pinout files for different Atmel processors.
One of them is named "ATmega_xx4.h".
If you had installed the Library you would have found this folder.
This is the contents of the file I am talking about that is installed with the library.


Code: [Select]
/** \file
   SPI and timer pins for the ATmega164/324/644.  Don't edit these.  All
   changeable pins are defined in tlc_config.h */  



Quote
T rust me I did go and look at the file. Which is why I am confused, I thought there would be a pin on the TLC5940 that you connect the ss pin and it didn't say in the library file where on the TLC5940 it is. but it seems once again I am wrong. Am I correct in saying this? So I just need to have ss pin defined in the library but I don't actually hook it up with the. TLC5940 right?


Quote
Did you install the TLC5940 Library ?
If you install it and look in the library folder, you will see a subdirectory named "Pinouts"
If you look in that subdirectory you will see all the pinout files for different Atmel processors.
One of them is named "ATmega_xx4.h".
If you had installed the Library you would have found this folder.

 
Quote
I have not install the library file instead I have looked at it using word wrap.


Still you have not installed the Library. I am trying to be patient but really this is difficult.   You have to install the library to see the file (unless you use the zip file viewer). The ATmega_xx4.h contains a statement that reads this:

Code: [Select]
/** \file
   SPI and timer pins for the ATmega164/324/644.  Don't edit these.  All
   changeable pins are defined in tlc_config.h */  


I have attached the ATmega_xx4.h and the tlc_config.h file as well as Word text file copies of these two.
As you noticed,  the pinouts file only mentions these:

Code: [Select]
SPI and timer pins for the ATmega164/324/644.   (but NOT the 1284)

so I cannot say for certain that it will work. One thing is for sure , these files are part of the library. If you read my last post you know that the these files also mention the SS pin.

From the ATmega_xx4.h file in the Pinouts folder:

Quote
/** SS will be set to output as to not interfere with SPI master operation.
   If you have changed the pin-outs and the library doesn't seem to work
   or works intermittently, make sure this pin is set correctly.  This pin
   will not be used by the library other than setting its direction to
   output. */
#define TLC_SS_PIN       PB4
#define TLC_SS_DDR       DDRB


Quote
Trust me I did go and look at the file. Which is why I am confused, I thought there would be a pin on the TLC5940 that you connect the ss pin and it didn't say in the library file where on the TLC5940 it is. but it seems once again I am wrong. Am I correct in saying this?  


How can you look at the file if you didn't install the Library ? How can you look at the file I attached in the last post and not see this ?
Quote
/** SS will be set to output as to not interfere with SPI master operation.
   If you have changed the pin-outs and the library doesn't seem to work
   or works intermittently, make sure this pin is set correctly.  This pin
   will not be used by the library other than setting its direction to
   output. */
#define TLC_SS_PIN       PB4
#define TLC_SS_DDR       DDRB


And now you are saying this?
Quote
So I just need to have ss pin defined in the library but I don't actually hook it up with the. TLC5940 right?  


No. I am NOT saying that. I am saying AGAIN to drink 5 cups of coffee and read the ATmega_xx4.h file in the
PINOUTS folder. I attached this file to my last post. That file SPELLS OUT THE PINS TO USE FOR EVERYTHING. YOU NEED TO
CONNECT THOSE 1284 PINS (THE ONES IN THE ATmega1284PA-pinout.png image file.  You read the ATmega_xx4.h file  FIRST
THEN LOOK AT THE PINOUTS IMAGE FILE AND FIND THOSE PINS ON THE IMAGE FILE AND WRITE THOSE DOWN AND USE THOSE PINS . THE PINS IDENTIFIED ARE THE ONES YOU CONNECT AND THEIR PIN NAME IS SPECIFIED IT THE .h file. You write that pin name down , then look at the pinouts  image file and you can see where those pins are. Those are the pins you connect .
Understand ?
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

raschemmel

#20
Mar 27, 2014, 03:39 pm Last Edit: Mar 27, 2014, 07:30 pm by raschemmel Reason: 1
Quote
So I just need to have ss pin defined in the library but I don't actually hook it up with the. TLC5940 right?


Quote
This is the ONLY SPI pin on an arduino UNO that is redefinable , meaning you can change the pin number in the code to any pin you want because it is not hardcoded as a SPI pin like the other three SPI pins I already mentioned.  


Quote
but I don't actually hook it up with the. TLC5940 right?


NO. THAT IS NOT WHAT I SAID. Redefinable means it doesn't have to be THAT pin but if you don't want to use that pin you can choose ANOTHER PIN but you MUST CHOOSE SOME PIN .
Is that clear ? I recommend that you use the same pin that is labeled SS on the 1284 PINOUT IMAGE FILE.
Code: [Select]
/** SS will be set to output as to not interfere with SPI master operation.
   If you have changed the pin-outs and the library doesn't seem to work
   or works intermittently, make sure this pin is set correctly.  This pin
   will not be used by the library other than setting its direction to
   output. */
#define TLC_SS_PIN       PB4
#define TLC_SS_DDR       DDRB

LOOK AT THE PINOUT IMAGE FILE
Quote
PIN PB4 is physical pin #5
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

account001

fisrtly, you can onpen .h files using notepad and wordpad. Becuase i didn't have the library installed, i open the zip file, right click on the .h files, choose open, select open with  installed programs, then i select the wordpad to open it. i have attached a screen shot that shows the chip_includes.h file opened in word pad. i am not trying to prove you wrong, just sharing knowledge.

About the SS pin, i know where the defalut SSpin is on the atmega1284, like you said
Code: [Select]
#define TLC_SS_PIN       PB4
#define TLC_SS_DDR       DDRB

what i don't understand is:
Code: [Select]
/** SCK (Sanguino digital pin 7) -> SCLK (TLC pin 25) */
, the file tells you where to connect the SCK to on the tlc which is TLC pin 25
but for the SS pin, it does not tell you which is the corresponding TLC pin. To my understanding there isn't a corresponding SSPin on the tlc5940, and hence my confusion.
so i connect one end of the wire to this pin, where does the other end wire connect to? this is what i don't know.
i thank you very much for your patience.
p.s. From another post i was informed the tlc5940 is not exactly suitable for my project so i might need to change the LED driver.

raschemmel

#22
Mar 27, 2014, 11:13 pm Last Edit: Mar 27, 2014, 11:46 pm by raschemmel Reason: 1
This is from the Basic Use Example sketch from the Library. I gave you this back in Reply#13. (We are now on Reply#25)
Everything you need is in the information I have given you. You obviously didn't even look at this sketch or you would have seen this.

Code: [Select]
/*
   Basic Pin setup:
   ------------                                  ---u----
   ARDUINO   13|-> SCLK (pin 25)           OUT1 |1     28| OUT channel 0
             12|                           OUT2 |2     27|-> GND (VPRG)
             11|-> SIN (pin 26)            OUT3 |3     26|-> SIN (pin 11)
             10|-> BLANK (pin 23)          OUT4 |4     25|-> SCLK (pin 13)
              9|-> XLAT (pin 24)             .  |5     24|-> XLAT (pin 9)
              8|                             .  |6     23|-> BLANK (pin 10)
              7|                             .  |7     22|-> GND
              6|                             .  |8     21|-> VCC (+5V)
              5|                             .  |9     20|-> 2K Resistor -> GND
              4|                             .  |10    19|-> +5V (DCPRG)
              3|-> GSCLK (pin 18)            .  |11    18|-> GSCLK (pin 3)
              2|                             .  |12    17|-> SOUT
              1|                             .  |13    16|-> XERR
              0|                           OUT14|14    15| OUT channel 15
   ------------                                  --------

   -  Put the longer leg (anode) of the LEDs in the +5V and the shorter leg
        (cathode) in OUT(0-15).
   -  +5V from Arduino -> TLC pin 21 and 19     (VCC and DCPRG)
   -  GND from Arduino -> TLC pin 22 and 27     (GND and VPRG)
   -  digital 3        -> TLC pin 18            (GSCLK)
   -  digital 9        -> TLC pin 24            (XLAT)
   -  digital 10       -> TLC pin 23            (BLANK)
   -  digital 11       -> TLC pin 26            (SIN)
   -  digital 13       -> TLC pin 25            (SCLK)

 


Quote
so i connect one end of the wire to this pin, where does the other end wire connect to?


Quote
10|-> BLANK (pin 23)  


(see above . Pin -10 is the default SS pin on an UNO. It goes to BLANK (TLC- pin-23)
ANSWER: TLC-PIN-23 (BLANK).

p.s.- [quoteFrom another post i was informed the tlc5940 is not exactly suitable for my project ] [/quote]
What other post ? (link ?)


Feel free to click my karma button if you found my input helpful....
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

account001

Thanks for the answer, i sorry for being a burden to you.
the other post is in the project gudience section http://forum.arduino.cc/index.php?topic=228843.msg1652746#msg1652746 called 'microduino(Atmega1284p) with tlc5940 data throughput calculation help needed'

Go Up