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:
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:
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