Hi all,
Good day. I am trying to do interfacing TLC5940NT with Atmega32. I read the TLC5940NT datasheet. But i didn't understand well. And i tried to do program in atmel studio 6.2. In this i am getting LED is always off. I don't know whether my attempt is correct or not. And also i don't know my code and circuit are correct. i feel the problem is in my code, bcoz i haven't understand clearly. Can you please give me a start up code. I confused with this how to start and i struggled with this. my Code and circuit is:
/* * PWM_TLC5940NT.c * * Created: 12/12/2014 4:53:16 PM * Author: Dev5 */ #define F_CPU 8000000UL #include <avr/io.h> #include <avr/pgmspace.h> #include <util/delay.h> #include <stdio.h> void uart0_init(void) { UCSRA=0x00; UCSRB=0x18; UCSRC=0x06; UBRRH=0x00; UBRRL=0x33; } void transmitByte( unsigned char data ) { while ( !(UCSRA & (1<<UDRE)) ) ; /* Wait for empty transmit buffer */ UDR = data; /* Start transmition */ } void transmitString(char* string) { while (*string) transmitByte(*string++); } int main(void) { unsigned int ipwm; DDRB = (1<<PB5)|(1<<PB7)|(1<<PB4); PORTB |= (1<<PB4); // CS pin is not active SPCR = (1<<SPE)|(1<<MSTR); // Enable SPI, Master, set clock rate fck/2 SPSR |= (1<<SPI2X); _delay_ms(100); DDRD |= (1<<PD4)|(1<<PD5); //OC1A, OC1B outputs TCCR1A = (2<<COM1A0)|(2<<COM1B0)|(2<<WGM10); //PWM#14, active-high LEDs TCCR1B = (3<<WGM12)|(3<<CS10); //PWM#14, div64 ICR1 = F_CPU/64/100 - 1; //OVF @ 100Hz TIMSK |= (1<<TOV1); uart0_init(); _delay_ms(500); transmitString("\n\n\nin main"); while(1) { //TODO:: Please write your application code transmitString("\nin loop"); ipwm=0; ipwm++; OCR0 = ipwm; if(ipwm == 255) { transmitString("\nipwm=255"); PORTD = 0xFF; ipwm = 0; } } return 0; // Standard Return Code }