-3

I have interfaced the PT6965 led controller with Pic32 over SPI using microchip harmony. My problem is I am unable to understand what data/ commands to write to led controller using spi that will turn on the 3 rgb leds connected to the led controller. I have read the PT6965 datasheet and they have mentioned how to use data commands but I am unable to understand how I should use them. Can someone please give me a simple example how I can turn on e.g the red led.

My overall project structure

Pic32-> SPI -> LED Controller -> RGB LED

The leds are connected as follows.

RED LED -> PIN No.20 (SG12/ GR7)

Blue LED -> PIN No.19 (SG11)

Green LED -> PIN No.18 (SG10/ KS10)

The link to PT6965 led controller datasheet "http://www.princeton.com.tw/Portals/0/Product/PT6965.pdf"

abdullah
  • 65
  • 10
  • Are you using direct register access with minimal additional libraries, or any sort of framework? – Thomas Jager Jul 19 '18 at 12:34
  • I am using microchip harmony framework. But it is just to setup spi. – abdullah Jul 19 '18 at 12:35
  • I'm reading through the datasheet. Have you tried anything? Also, have you taken note of the fact that you need to properly control the STB pin? – Thomas Jager Jul 19 '18 at 12:37
  • Also, this is designed to be used as a segment-display controller. What configuration are your LED cathodes in? – Thomas Jager Jul 19 '18 at 12:40
  • I have not tried sending any data as I am unable to understand what command or data byte to send or how to write to a particular pin e,g pin 20 for red led. As for the stb pin I have configured it and can make it 1or 0. – abdullah Jul 19 '18 at 12:42
  • Yes it is a segment display controller but cant I use it to just turn on/off the led connected to a specific pin? – abdullah Jul 19 '18 at 12:44
  • You can, but because it's a display controller, it'll only spend a fraction of it's time driving the LEDs, the rest of it will be spent trying to drive non-connected LEDs. – Thomas Jager Jul 19 '18 at 12:46
  • Can you please explain me what command/ data byte I should write to turn on the led or if I want to write 1 to pin 20 how I can do that? I am not very concerned about any time spent / delays at the moment – abdullah Jul 19 '18 at 12:52
  • Do I need to write to any specific register of LED Controller or send a specific byte to communicate with pin20/ red led? – abdullah Jul 19 '18 at 12:55
  • Not the same HW, but your problem is generic, i.e. _how to write data via SPI using C?_ so take a look _[HERE](https://www.maximintegrated.com/en/app-notes/index.mvp/id/4184)_. – ryyker Jul 19 '18 at 12:55
  • @ryyker That doesn't really help. The issue doesn't seem to be sending data, but what data to send. – Thomas Jager Jul 19 '18 at 12:56
  • I do know how to write data via SPI but I am unsure what data to write. Is there a specific command to be written or just writing 1 to pin 20 will turn on the red led? And if so how do I write 1 to pin 20 – abdullah Jul 19 '18 at 12:58
  • 2
    @ThomasJager - OP does not contain enough information for you to make such a broad statement about what will or will not help here. The data sheet for specific device is clear about what to send, and the example code in the link provides generic method how to send it. – ryyker Jul 19 '18 at 12:59
  • @ryyker They've been very clear that they don't understand what commands to send to the controller. – Thomas Jager Jul 19 '18 at 13:00
  • 1
    @ThomasJager: We are not to explain how to read datasheets. That's a skill OP is expected to have when asking here or on electronics.se (which would be more appropriate for such questions anyway). – too honest for this site Jul 19 '18 at 15:03

1 Answers1

1

Start with STB high. Bring it low before every command, and bring it high after you send the command before sending the next.

Since you're using SG past 11, you'll need to change the display mode (Commands 1 in the datasheet) before you write data. This can be done by sending 0b00000000 to set the controller to 4-digit 14-segment mode. (This is only necessary because you are using the SG12 pin. It also means less addresses to write to later.)

Next, you want to set the data settings (Commands 2). This starts with 0b0100 and has 4 more bits. The next bit is a 0 because we're not in test mode. You'll want to increment the address each data write, so do a 0 next. The display controller is also designed to read a key matrix, but you aren't using that, so we want to add a final 00. This gives 0b01000000.

The next part is the hard part, because you want to set address you need to write to. This is where I can't easily help you, you need to understand this. Commands 3 shows all the addresses you can write to. You want to specifically affect segments 10 through 12 of every digit. This means that you want to write to bytes 1 to 3 of all the bytes at odd-numbered addresses. Since you aren't using the other pins, the easiest and fastest way to do this is to go through all the addresses. Since you don't care what you write to even addresses, you can write the same you do to odd ones. For simplicity, you'll want to start by setting the address to 0 by sending the code for addresses: 0b1100 followed by your address 0b0000. This gives 0b11000000. Now, without pulling the STB back high, start sending your data bytes. On every write, the address will be incremented. Since we previously set the number of digits to 4, we only need to go up to address 0x7. You can do this by sending 8 bytes that contain 0b0000RBG0, where the letters represent the state of the colours. Once you do this, you can set the strobe high agatin. (This assumes that the cathodes are all connected to GND so that the digit canthodes are ignored)

This is of course the very minimum. It would be far better to only write the bits you need, and leave the rest off, but I'm trying to keep things simple, even if it's not the right way of doing things.

You'll want to set some other display control settings (Commands 4). These start with 0b1000. You then want a 1 to keep the display on, followed by 111 to keep the display lit as much as possible. This gives 0b10001111.

This component is not designed for beginner use, and you are using it for an unintended purpose that far overcomplicates things. You are abusing the purpose of the part. While it's a good learning experience, you have to actually try to learn. Take the time to read the datasheet because it's likely that it won't work based off what I've said depending on how it's set up. I've tried to explain why each command is sent, not just what it is. You need to understand the commands before you use this. Go through the datasheet, and look at every command to see why I recommended to do that.

Thomas Jager
  • 4,836
  • 2
  • 16
  • 30