Interfacing TLC5940NT with PIC18F13K50

Discussion in 'Embedded Systems and Microcontrollers' started by ruuhkis, Feb 4, 2012.

  1. ruuhkis

    Thread Starter New Member

    Jan 19, 2012
    8
    0
    Hello again guys!

    I am quite a new to SPI bus but I'd like to learn more about it and make my TLC5940NT function like I want it but there's just couple of things I'd like to ask from you that I don't know about or am quite sure about.

    I know that its required to have same clock speed on master and on the slave to synchronize the data received and sent. In PIC18F13K50 theres this pin for "Synchronous serial clock input/output for SPI mode", so should I use that for TLC5940's SCLK and GSCLK which are for Data shift clock frequency and Grayscale clock frequency? Also I know that my PIC18F13K50 runs on clock speed of 48mhz, unfortunately the max speed of clock TLC5940 can use is 30mhz, what should I do? Or do this have something to do with that, when I initialize the SPI interace on C code it takes the sync mode as parameter, which is some kind of divider for oscillator speed, right? But how do I know what sync mode I should use to make it sync correctly? Or will it know what to do if the clock speed is under 30mhz? So if I used the serial clock input/output to the SCLK and GSCLK and used SPI_FOSC_64 as parameter, would it work? and if not what should i do with those clocks to make it sync correctly?

    PIC18F13K50 datasheet

    TLC5940NT datasheet
     
  2. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,887
    1,014
    First off please use a carriage return once in a while it makes a big paragraph like that more readable.

    If your MCU runs at 30MHZ, the best the SPI will run is FOSC / 4. But check your datasheet because there are other dividers. You should be able to divide up to 64.

    If the max of your MCU is 30MHZ, that does not mean you need to run it at 30MHZ. In fact it may be unreliable at max frequency. Plus it won't be very efficient at that speed. If the MCU is battery driven you will be eating batteries like crazy. Many applications work just fine at 1MHZ or less.
     
  3. ruuhkis

    Thread Starter New Member

    Jan 19, 2012
    8
    0
    Thanks for the tip and specially the answer. But is it correct to hook up both, SCLK and GSCLK, to the synchronous serial clock output?
    Also do I need to configure anything like baud rate, as if I remember correctly it must be the same on the master and on the slave, or does the clock configure it or something?
    Thanks again! :)
     
  4. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,887
    1,014
    I do not know what GSCLK is. Check you datasheet but you will need only one clock SCLK.

    There is only one clock in SPI controlled by the master. There is no "baud rate" but there is clock speed. That is usually based off of FOSC and then divided down as needed by setting the proper bits in the configuration register.

    The clock speed can even change over time. It does not matter as long as the master is controlling it and you don't exceed the clock speed of your slave device.

    You will need a chip select for your device again controlled by the master. Though I suppose you can tie the CS low on the device but that would mean only one SPI device.
     
  5. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,887
    1,014
Loading...