Part Number:TPS92661-Q1
Hello,
I am trying to use a tps 92661 on a LED adaptive headlight, and i am having some trouble in communicate between the TPS and the MCU (Arduino MEGA).
I am using a data logger and it was suppose that when i write a message the TPS should answer me, but nothing happens after sending the message.
![]()
192 = 0xC0
193 = 0xC1
145 = 0x91
140 = 0x8C
Can anyone help me?
#define ENABLE_PIN 5 //PIN 4 DO TPS
#define CLOCKOUT 10 //PIN 8 DO TPS
void lmm_wr_1_reg(uint8_t lmm, uint8_t regaddr, uint8_t data);
void lmm_uart_xmit(uint8_t data);
const int prescale = 1;
const int ocr2aval = 3;
void setup() {
pinMode(ENABLE_PIN, OUTPUT);
digitalWrite(ENABLE_PIN, LOW);
pinMode(CLOCKOUT, OUTPUT);
TCCR2A = ((1 << WGM21) | (1 << COM2A0));
// Set Timer 2 No prescaling (i.e. prescale division = 1)
//
// CS22:0 = 001: Use CPU clock with no prescaling
// CS2 bits 2:0 are all in TCCR2B
TCCR2B = (1 << CS20);
// Make sure Compare-match register A interrupt for timer2 is disabled
TIMSK2 = 0;
// This value determines the output frequency
OCR2A = ocr2aval;
// put your setup code here, to run once:
Serial.begin(9600);
delay(100);
Serial1.begin(125000);
delay(100);
digitalWrite(ENABLE_PIN, HIGH);
delay(100);
while (Serial.available() == 0);
while (Serial.available() != 0)
Serial.read();
Serial.println("READ CLOCK SOURCE");
Serial.println(lmm_rd_1_reg(0x00, 0xc1));
while (Serial.available() == 0);
while (Serial.available() != 0)
Serial.read();
Serial.println("SET CLOCK SOURCE");
lmm_wr_1_reg(0x00, 0xc1, 0b00000011); // tps 0, SYSCFG SCMASTER 1 PWR1
//lmm_wr_1_reg(0x01, 0xc1, 0b00000001); // tps 1, SYSCFG SCMASTER 0 PWR1
while (Serial.available() == 0);
while (Serial.available() != 0)
Serial.read();
Serial.println("READ CLOCK SOURCE");
Serial.println(lmm_rd_1_reg(0x00, 0xc1));
while (Serial.available() == 0);
while (Serial.available() != 0)
Serial.read();
Serial.println("SET LEDS");
lmm_wr_1_reg(0x00, 0xB1, 0b00001000); //ENABLE DO LED 12 (12A9)
lmm_wr_1_reg(0x00, 0x0D, 0b00000000); //LED12
lmm_wr_1_reg(0x00, 0x2D, 0b11111111); //LED12
while(1);
}
King regards
Vasco Mendes