Hola
He podido después de mucho tiempo escribir y pedirle al CS5463. Sigo teniendo problemas cuando leo los datos que vuelven del Cirrus al PIC.
Estoy tratando de leer el cycle count register que se que vale 4000 decimal, cuando leo deberia obtener en el MSB 0x00 , el del medio 0x0F y en el LSB 0xA0. Actualmente estoy obteniendo 0x00 0x00 y 0x00.
Sin embargo en el osciloscopio veo perfecto que el cirrus me manda el data que espero.
Como comentaba en post anteriores, me sonaba que iba a ver algún problema en el manejo del buffer al mismo tiempo. Adjunto el código de SPI y de la rutina que implementé para leer el Cycle Count Register.
CODIGO SPI:
///////////////////////////////////////////////////////////////////
//Retorno: void
//Parametro: char ; El dato a enviar
//Descripcion: Envia un dato por el puerto SPI
///////////////////////////////////////////////////////////////////
void SPI_write(char data){
char dummy=0x00;
SSPIF =0;
dummy=SSPBUF;
SSPBUF = data;
while(SSPIF == 0){}
}
///////////////////////////////////////////////////////////////////
//Retorno: char ; el dato recibido
//Parametro: void
//Descripcion: Recibe un dato por el puerto SPI
///////////////////////////////////////////////////////////////////
char SPI_read(void){
char data;
while(!BF){};
data = SSPBUF;
return data;
}
CODIGO DE PEDIDO DE LECTURA
//Retorno: void
//Parametro: void
//Descripcion: Funcion para pedir el voltaje el cual devuelvo los datos leidos
// en los tres registros datoH, datoM, datoL.
//////////////////////////////////////////////////////////////////////////////////////
void CIRRUS_readCycleCountReg(void){
RC2 = LOW; //CS =0
SPI_write(0x0A);
SPI_read();
SPI_write(0xFF);
datoH = SPI_read();
SPI_write(0xFF);
datoM = SPI_read();
SPI_write(0xFF);
datoL = SPI_read();
RC2 = HIGH; //CS =1
}
Uploaded with
ImageShack.us