Hallo zusammen
Ich bin dabei die tlc5940 libary auf mein Atmega1284 zu Programmieren, nachdem ich die Pins auf das 1284 konfiguiert habe bleibt das programm bei der Tlc.init() stehen, ich gehe davon aus das es an den Timer Setup liegt. Nach langem zweifeln und versuchen bin ich auf diese Seite gestossen:
http://bascom-forum.de/showthread.php?3595-Capture-Funktion-Timer1-geht-nicht-am-Atmega1284P/
Aber leider hilft das mir nicht weiter da ich keinerlei Erfahrungen mit den Timern habe...
Ich hoffe ich könnt dabei behilflich sein die Libary auf mein Atmega1284 laufen zu bringen.
DIe Pins habe ich wie gefolgt abgeändert:
#ifndef ATMEGA1284p_H
#define ATMEGA1284p_H
/** \file
SPI and timer pins for the Atmega. Don't edit these. All
changeable pins are defined in tlc_config.h */
/** VPRG (Atmega1284 Pin 8) -> VPRG (TLC pin 27) */
#define DEFAULT_VPRG_PIN PB6
#define DEFAULT_VPRG_PORT PORTB
#define DEFAULT_VPRG_DDR DDRB
/** XERR (Atmega1284 Pin 22) -> XERR (TLC pin 16) */
#define DEFAULT_XERR_PIN PD7
#define DEFAULT_XERR_PORT PORTD
#define DEFAULT_XERR_DDR DDRD
#define DEFAULT_XERR_PINS PIND
/** SIN (Atmega1284 Pin 6) -> SIN (TLC pin 26) */
#define DEFAULT_BB_SIN_PIN PB5
#define DEFAULT_BB_SIN_PORT PORTB
#define DEFAULT_BB_SIN_DDR DDRB
/** SCLK (Atmega1284 Pin 8) -> SCLK (TLC pin 25) */
#define DEFAULT_BB_SCLK_PIN PB7
#define DEFAULT_BB_SCLK_PORT PORTB
#define DEFAULT_BB_SCLK_DDR DDRB
/** MOSI (Atmega1284 Pin 7) -> SIN (TLC pin 26) */
#define TLC_MOSI_PIN PB5
#define TLC_MOSI_PORT PORTB
#define TLC_MOSI_DDR DDRB
/** SCK (Atmega1284 Pin 8) -> SCLK (TLC pin 25) */
#define TLC_SCK_PIN PB7
#define TLC_SCK_PORT PORTB
#define TLC_SCK_DDR DDRB
// SS (Mega pin 53)
/** SS will be set to output as to not interfere with SPI master operation.
If you have changed the pin-outs and the library doesn't seem to work
or works intermittently, make sure this pin is set correctly. This pin
will not be used by the library other than setting its direction to
output. */
#define TLC_SS_PIN PB4
#define TLC_SS_DDR DDRB
/** OC1A (Atmega1284 Pin 19) -> XLAT (TLC pin 24) */
#define XLAT_PIN PD5
#define XLAT_PORT PORTD
#define XLAT_DDR DDRD
/** OC1B (Atmega1284 Pin 18) -> BLANK (TLC pin 23) */
#define BLANK_PIN PD4
#define BLANK_PORT PORTD
#define BLANK_DDR DDRD
/** OC2B (Atmega1284 Pin 20) -> GSCLK (TLC pin 18) */
#define GSCLK_PIN PD6
#define GSCLK_PORT PORTD
#define GSCLK_DDR DDRD
#endif
Hier die tlc.init mit dem Timer Setup:
void Tlc5940::init(uint16_t initialValue)
{
//Serial.println(zaehler);
/* Pin Setup */
XLAT_DDR |= _BV(XLAT_PIN);
BLANK_DDR |= _BV(BLANK_PIN);
GSCLK_DDR |= _BV(GSCLK_PIN);
#if VPRG_ENABLED
VPRG_DDR |= _BV(VPRG_PIN);
VPRG_PORT &= ~_BV(VPRG_PIN); // grayscale mode (VPRG low)
#endif
#if XERR_ENABLED
XERR_DDR &= ~_BV(XERR_PIN); // XERR as input
XERR_PORT |= _BV(XERR_PIN); // enable pull-up resistor
#endif
BLANK_PORT |= _BV(BLANK_PIN); // leave blank high (until the timers start)
tlc_shift8_init();
setAll(initialValue);
update();
disable_XLAT_pulses();
clear_XLAT_interrupt();
tlc_needXLAT = 0;
pulse_pin(XLAT_PORT, XLAT_PIN);
/* Timer Setup */
/* Timer 1 - BLANK / XLAT */
TCCR1A = _BV(COM1B1); // non inverting, output on OC1B, BLANK
TCCR1B = _BV(WGM13); // Phase/freq correct PWM, ICR1 top
OCR1A = 1; // duty factor on OC1A, XLAT is inside BLANK
OCR1B = 2; // duty factor on BLANK (larger than OCR1A (XLAT))
ICR1 = TLC_PWM_PERIOD; // see tlc_config.h
/* Timer 2 - GSCLK */
#if defined(TLC_ATMEGA_8_H)
TCCR2 = _BV(COM20) // set on BOTTOM, clear on OCR2A (non-inverting),
| _BV(WGM21); // output on OC2B, CTC mode with OCR2 top
OCR2 = TLC_GSCLK_PERIOD / 2; // see tlc_config.h
TCCR2 |= _BV(CS20); // no prescale, (start pwm output)
#elif defined(TLC_TIMER3_GSCLK)
TCCR3A = _BV(COM3A1) // set on BOTTOM, clear on OCR3A (non-inverting),
// output on OC3A
| _BV(WGM31); // Fast pwm with ICR3 top
OCR3A = 0; // duty factor (as short a pulse as possible)
ICR3 = TLC_GSCLK_PERIOD; // see tlc_config.h
TCCR3B = _BV(CS30) // no prescale, (start pwm output)
| _BV(WGM32) // Fast pwm with ICR3 top
| _BV(WGM33); // Fast pwm with ICR3 top
#else
TCCR2A = _BV(COM2B1) // set on BOTTOM, clear on OCR2A (non-inverting),
// output on OC2B
| _BV(WGM21) // Fast pwm with OCR2A top
| _BV(WGM20); // Fast pwm with OCR2A top
TCCR2B = _BV(WGM22); // Fast pwm with OCR2A top
OCR2B = 0; // duty factor (as short a pulse as possible)
OCR2A = TLC_GSCLK_PERIOD; // see tlc_config.h
TCCR2B |= _BV(CS20); // no prescale, (start pwm output)
#endif
TCCR1B |= _BV(CS10); // no prescale, (start pwm output)
update();
}