Go Down

Topic: TM1914 ic rgb (Read 545 times) previous topic - next topic

Bartleboom

Hi,
I'm trying to drive some rgb lights that have TM1914 inside. It's a 800Khz signal similar to WS2811 but it is inverted. Anyway, I got it works for a while but the lights immediately switch off.
I attached the original datasheet (in Chinese) and the translation.
Any suggestions?

PaulRB

it works for a while but the lights immediately switch off.

Any suggestions?
Maybe you could explain the problem without contradicting yourself.

Also post your code and schematic.

Bartleboom

#2
May 24, 2019, 02:53 pm Last Edit: May 24, 2019, 02:57 pm by Bartleboom
Hi,
I'm trying to drive some rgb lights that have TM1914 inside. It's a 800Khz signal similar to WS2811 but it is inverted. Anyway, I got it works for a while but the lights immediately switch off.
I attached the original datasheet (in Chinese) and the translation.
Any suggestions?
Hi Paul, I mean that the ic recognize the color I choose (Red is 0xFF, 0x00, 0x00) but after a while it switch off.

The code is as follow:

Code: [Select]

int8_t pin = 6;        
volatile uint8_t *port;
uint8_t pinMask;  
uint8_t  hi, lo;            
  
void setup() {

  pinMode(pin, OUTPUT);
  digitalWrite(pin, HIGH);
  delay(1000);
  port    = portOutputRegister(digitalPinToPort(pin));
  pinMask = digitalPinToBitMask(pin);  
  hi   = *port |  pinMask;
  lo   = *port & ~pinMask;

}

void loop() {

  show();  
  
  while (1) {}

  
}




the function show() send each bit as follow:

Code: [Select]
void show5(void) {


asm volatile(
    // This is bit 1
    "st %a[port], %[lo]"       "\n\t" // 2    PORT = low     (T =  2)
    "nop"                      "\n\t" // 1                   (T =  3)
    "nop"                      "\n\t" // 1                   (T =  4)
    "nop"                      "\n\t" // 1                   (T =  5)
    "nop"                      "\n\t" // 1                   (T =  6)
    "nop"                      "\n\t" // 1                   (T =  7)
    "nop"                      "\n\t" // 1                   (T =  8)
    "nop"                      "\n\t" // 1                   (T =  9)
    "nop"                      "\n\t" // 1                   (T =  10)
    "nop"                      "\n\t" // 1                   (T =  11)
    "nop"                      "\n\t" // 1                   (T =  12)
    "st %a[port], %[hi]"       "\n\t" // 2    PORT = hi      (T =  14)
    "nop"                      "\n\t" // 1                   (T =  15)
    "nop"                      "\n\t" // 1                   (T =  16)
    "nop"                      "\n\t" // 1                   (T =  17)
    "nop"                      "\n\t" // 1                   (T =  18)
    "nop"                      "\n\t" // 1                   (T =  19)
    "nop"                      "\n\t" // 1                   (T =  20)

.....
.....
.....

// this is bit 0


   "st %a[port], %[lo]"       "\n\t" // 2    PORT = low     (T =  2)
    "nop"                      "\n\t" // 1                   (T =  3)
    "nop"                      "\n\t" // 1                   (T =  4)
    "nop"                      "\n\t" // 1                   (T =  5)
    "nop"                      "\n\t" // 1                   (T =  6)
    "st %a[port], %[hi]"       "\n\t" // 2    PORT = hi      (T =  8)
    "nop"                      "\n\t" // 1                   (T =  9)
    "nop"                      "\n\t" // 1                   (T =  10)
    "nop"                      "\n\t" // 1                   (T =  11)
    "nop"                      "\n\t" // 1                   (T =  12)
    "nop"                      "\n\t" // 1                   (T =  13)
    "nop"                      "\n\t" // 1                   (T =  14)
    "nop"                      "\n\t" // 1                   (T =  15)
    "nop"                      "\n\t" // 1                   (T =  16)
    "nop"                      "\n\t" // 1                   (T =  17)
    "nop"                      "\n\t" // 1                   (T =  18)
    "nop"                      "\n\t" // 1                   (T =  19)
    "nop"                      "\n\t" // 1                   (T =  20)


....
....
....


        : [port]  "+e" (port)
        : [hi]     "r" (hi),
          [lo]     "r" (lo));
}



Keeping in mind that Atmega328p is configured with 16.000.000 clk per second

For 800Khz signal each bit is 1.250 ns (20 clk)


In my sketch I send 9 bytes:

0xFF 0xFF 0xFA 0x00 0x00 0x05 (as per Datasheet Setting Mode DIN Mode)

and then I send 1 pixel display data:

0xFF 0x00 0x00 (Red color)


Then I send the Reset signal which is the Pin High for at least 200uS



PaulRB

What are these lines supposed to do?
Code: [Select]
  hi   = *port |  pinMask;
  lo   = *port & ~pinMask;


This line of code
Code: [Select]
  while (1) {}
will stop the code from doing anything until you press reset. So if something happens after some time, it is not because of the code. Something else must be happening.


How many LEDs are connected? How are you powering the circuit?

Bartleboom

Quote
What are these lines supposed to do?
Code: [Select]
 hi   = *port |  pinMask;
  lo   = *port & ~pinMask;

These lines save the value of PORTx register when is HIGH or LOW
this value is passed as argument in the assembly instruction ST
(turn on and off the pin)

Quote
This line of code
Code: [Select]
 while (1) {}
will stop the code from doing anything until you press reset. So if something happens after some time, it is not because of the code. Something else must be happening.
before the "while" we have one call to show() function which should light on 1 pixel
if I remove the while the lights are always on because it sends always the data to IC


Quote
How many LEDs are connected? How are you powering the circuit?
I have two LEDs connected powered with 24V (ground is in common with arduino GND)

Go Up