Cirrus-logic AN74 Manual do Utilizador Página 9

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 14
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 8
AN74
AN74Rev2 9
/**************************************************************************************
* Routine - read_register
* Input - command
* Output - low_byte, mid_byte, high_byte
*
* This subroutine reads an internal register of the ADC
/**************************************************************************************/
void read_register(char command){
if(mode == 1) P1 = 0xF4; /*Assert CS
if necessary */
transfer_byte(command); /*Transfer Command Byte to CS5525/6/9*/
high_byte = receive_byte(); /*Receive Command Byte from CS5525/6/9*/
mid_byte = receive_byte(); /*Receive Command Byte from CS5525/6/9*/
low_byte = receive_byte(); /*Receive Command Byte from CS5525/6/9*/
if(mode == 1)P1 = 0xF5; /*Deassert CS
if necessary */
}
/**************************************************************************************/
* Routine - acquire_conversion
* Input - command
* Output - Conversion results in memory locations HIGHBYTE, MIDBYTE and
* LOWBYTE. This algorithm performs only single conversions. If
* continuous conversions are needed the routine needs to be
* modified. Port flag is zero.
*
* HIGHBYTE MIDBYTE LOWBYTE
* 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
* 16-bit results MSB LSB 1 1 1 1 0 0 OD OF
* 20-bit results MSB LSB 0 0 OD OF
* This subroutine initiates a single conversion.
/**************************************************************************************/
void acquire_conversion(char command){
/*** Read Configuration Register to Prevent Previously Set Bits from being Altered ***/
read_register(0x94); /*Read Configuration Register*/
low_byte = low_byte|0x20; /*Assert Port Flag Bit*/
write_to_register(0x84,low_byte, mid_byte, high_byte);/*Actually Send Commands*/
/*Acquire a Conversion*/
if(mode == 1)P1 = 0xF4; /*Assert CS
if necessary*/
transfer_byte(0xC0); /*Transfer Command to CS5525/6/9*/
toggle_sdo(); /*Clear SDO*/
high_byte = receive_byte(); /*Receive Command Byte from CS5525/6/9*/
mid_byte = receive_byte(); /*Receive Command Byte from CS5525/6/9*/
low_byte = receive_byte(); /*Receive Command Byte from CS5525/6/9*/
if(mode == 1) P1 = 0xF5; /*Deassert CS
if necessary*/
}
Vista de página 8
1 2 3 4 5 6 7 8 9 10 11 12 13 14

Comentários a estes Manuais

Sem comentários