Good day to all,
Please i need your guide and support on how to solve this Problem.I am using 6 Outputs of TLC5971 to control the brightness of 6 Leds.Everything is working well except the fact that the Outputs are always ON whenever I power on the board.Based on the initialisation that i made,I expect the Outputs to be OFF whenever I power ON the board.I would be very grafeful if somebody could help me have a look through my code perhaps my initialisation code is wrong.Below are my lines of code:
void ClearClock() { PORTB &= ~(1 << PB3); } void SetClock() { PORTB |= (1 << PB3); } void ToggleClock() { _delay_us(50); SetClock(); _delay_us(50); ClearClock(); clockcount++; } void GenerateLatch() { _delay_us(400); } void SetData() { PORTD |= (1 << PD6); // Setzen } void ClearData() { PORTD &= ~(1 << PD6); // Rücksetzen } void send_16Bit(unsigned int data10) { int i=15; do { if (((data10 & (1<<i))>>i) == 1) SetData(); else ClearData(); ToggleClock(); i=i-1; } while (i >= 0); } void InitRegister() { // 0x25 = 100101b SetData(); ToggleClock(); ClearData(); ToggleClock(); ClearData(); ToggleClock(); SetData(); ToggleClock(); ClearData(); ToggleClock(); SetData(); ToggleClock(); SetData(); ToggleClock(); // OUTTMG (1=OUTx turned on/off at rising edge of clock ClearData(); ToggleClock(); // EXTGCK (0=internal Clock) SetData(); ToggleClock(); // TMGRST (Display timing reset mode) SetData(); ToggleClock(); // DSPRPT (auto Display repeat mode) ClearData(); ToggleClock(); // BLANK (0=LEDs on; 1=LEDs off) // global brightness correction for (int i=212; i>191; i--) { SetData(); ToggleClock(); a++; } // Greyscale Data a=0; for (int i=192; i>0; i--) { ClearData(); ToggleClock(); a++; } a=0; GenerateLatch(); } void SendLEDHeader(void) { // 0x25 = 100101b SetData(); ToggleClock(); ClearData(); ToggleClock(); ClearData(); ToggleClock(); SetData(); ToggleClock(); ClearData(); ToggleClock(); SetData(); ToggleClock(); SetData(); ToggleClock(); // OUTTMG (1=OUTx turned on/off at rising edge of clock ClearData(); ToggleClock(); // EXTGCK (0=internal Clock) ClearData(); ToggleClock(); // TMGRST (Display timing reset mode) SetData(); ToggleClock(); // DSPRPT (auto Display repeat mode) ClearData(); ToggleClock(); // BLANK (0=LEDs on; 1=LEDs off) // global brightness correction for (int i=212; i>191; i--) //^191 { SetData(); ToggleClock(); a++; } } void SetRegister_1(unsigned short LED0,unsigned short LED1, unsigned short LED2, unsigned short LED3, unsigned short LED4, unsigned short LED5) { SendLEDHeader(); send_16Bit(0); send_16Bit(0); send_16Bit(0); send_16Bit(0); send_16Bit(0); send_16Bit(0); send_16Bit(65535-LED5); send_16Bit(65535-LED4); send_16Bit(65535-LED3); send_16Bit(65535-LED2); send_16Bit(65535-LED1); send_16Bit(65535-LED0); } int main(void) { DDRB |= 1 <<PINB3; // PIN B3 Clock Output DDRD |= 1 <<PIND6; // PIN D6 Data Output InitRegister(); USART_Init(47); SetRegister_1(0,0,0,0,0,0); while(1) { clockcount=0; //wait_command(); UARTReceiver(); } }//
Thank you for the Support.Best regards.