Salve,
sto sbattendo la testa con la lettura dello status byte di questo sintetizzatore PLL della philips, in realta' sto preparando un prototipo di trasmettitore FM il cui oscillatore VCO è controllato da questo IC, gestito dal controller ARDUINO con la libreria wire, nell'invio degli byte MSB e LSB del programmable divider nessun problema, tanto è vero che il PLL viene agganciato e la frequenza generata dal VCO viene "LOCKATA" dal PLL, il mio problema è che quando vado a leggere lo "status byte" che mi deve dar conferma tramite il flag "FL" che se a 1 il PLL è agganciato, leggendo il valore in binario tramite un display LCD mi da o 0 o una serie di 8 bit di 10000000 che non hanno nessun significato, vi posto un segmento del codice che esegue, o meglio dovrebbe eseguire la lettura del chip stesso tramite il protocollo I2C e il datasheet del PLL, chiedendo a voi se qualcuno mi da' quanlche dritta.
Wire.requestFrom(0x61, 2); // request 2 bytes from slave device #0x61
if(Wire.available()) // if two bytes were received
{
locked = Wire.read();
Wire.endTransmission(0);
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(locked,BIN);
}
TSA5511.pdf (146 KB)
Confesso che anche per me la libreria Wire è un po' ostica da comprendere.
Tuttavia, io sapevo che prima di interrogare un dispositivo occorre iniziare una trasmissione:
Wire.beginTransmission(Adr); // device address
Wire.write(0x00); // set start address
Wire.endTransmission(); // invia dati
Wire.requestFrom(Adr, 2); // richiesta 2 byte
I = byte(Wire.read()); // 1° byte
K = byte(Wire.read()); // 2° byte
...
Si, nel codice viene normalmente eseguita prima la scrittura ed impostati per prima le modalita' di funzionamento, poi, pero' nella fase di lettura non ottengo che 10000000 per poi ritornare a zero!!
NON so'piu che pesci prendere.............nel datasheet ecco le info di read mode.
READ mode : R/W = 1 (see Table 2)
Data can be read out of the TSA5511 by setting the R/W bit to 1. After the slave address has been recognized, the
TSA5511 generates an acknowledge pulse and the first data byte (status word) is transferred on the SDA line (MSB first).
Data is valid on the SDA line during a high position of the SCL clock signal.
A second data byte can be read out of the TSA5511 if the processor generates an acknowledge on the SDA line. End of
transmission will occur if no acknowledge from the processor occurs.
The TSA5511 will then release the data line to allow the processor to generate a STOP condition.
When ports P3 to P7 are used as inputs, they must be programmed in their high-impedance state.
The POR flag (power-on reset) is set to 1 when VCC goes below 3 V and at power-on. It is reset when an end of data is
detected by the TSA5511 (end of a READ sequence).
Control of the loop is made possible with the in-lock flag FL which indicates (FL = 1) when the loop is phase-locked. The
bits I2, I1 and I0 represent the status of the I/O ports P7, P5 and P4 respectively. A logic 0 indicates a LOW level and a
logic 1 a HIGH level (TTL levels).
A built-in 5-level ADC is available on I/O port P6. This converter can be used to feed AFC information to the controller
from the IF section of the television as illustrated in the typical application circuit (Fig.5). The relationship between bits
A2, A1 and A0 and the input voltage on port P6 is given in Table 3.
Table 2 Read data format
Note to Table 2
Address selection
The module address contains programmable address bits (MA1 and MA0) which together with the I/O port P3 offers the
possibility of having several synthesizers (up to 3) in one system.
The relationship between MA1 and MA0 and the input voltage I/O port P3 is given in Table 4.
MSB LSB
Address 1 1 0 0 0 MA1 MA0 1 A byte 1
Status byte POR FL I2 I1 I0 A2 A1 A0 byte 2
POR power-on reset flag. (POR = 1 on power-on)
FL in-lock flag (FL = 1 when the loop is phase-locked)
I2, I1, I0 digital information for I/O ports P7, P5 and P4 respectively
A2, A1, A0 digital outputs of the 5-level ADC. Accuracy is 1/2 LSB (see Table 3)
MSB is transmitted first.
Ma nello sketch tu chiedi 2 byte ma ne leggi uno soltanto.
Se ho ben capito il funzionamento del PLL dovresti fare così:
Wire.beginTransmission(0x61); // device address
Wire.write(0x00); // set start address
Wire.endTransmission(); // invia dati
Wire.requestFrom(0x61, 1); // richiesta 1 byte
I = byte(Wire.read()); // 1° byte
...
O.k chiaro,
ma il risultato dello status byte che dovrebbe essere 11000001 invece mi da' sul display ma per un attimo solo 10000000 per poi ritornare a 0, inutile ribadire che nel momento della lettura il PLL è agganciato e quindi il secondo bit del MSB dello status byte deve essere a " 1 " --> 11000001
Ipotizzo: la libreria è a 7 bit di indirizzo e quella necessaria per il PLL dovrebbe essere ad 8 bit.
Le istruzioni della Wire dicono:
Note
There are both 7- and 8-bit versions of I2C addresses. 7 bits identify the device, and the eighth bit determines if it's being written to or read from. The Wire library uses 7 bit addresses throughout. If you have a datasheet or sample code that uses 8 bit address, you'll want to drop the low bit (i.e. shift the value one bit to the right), yielding an address between 0 and 127.
e tu correttamente hai eliminato il LSB con uno right shift ottenendo 0x61 (immagino essendo MA1 = 0 e MA0 = 1) ma forse la manovra non piace a quel PLL.
Sinceramente l'indirizzo l'ho ottenuto con lo scanner I2C che a dire il vero non mi ha mai dato rogne.
Ora non so' se dopo la richiesta di lettura dello status byte una volta terminata, il PLL deve essere in quanlche modo resettato da qualche NAK o similari affinche' restituisca nuovamente detto byte.........tu che dici?