Autor Tema: registros en DS1307en ccs  (Leído 1398 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado allennet

  • PIC16
  • ***
  • Mensajes: 108
registros en DS1307en ccs
« en: 24 de Junio de 2009, 23:41:15 »
hola  desde ya agradesco su respuestas

mi problemas es en el registros 0 del DS1307
quiero que el pic 16f877 sepa si ha estado en modo respaldo con la bateria

se que en el bit 7 del registro 0
0 estaba funcionando el RTC en modo respaldo por la bateria
1 no esta funcionando
el problema no se como hacer un condicional con ese bit en CCS pero
en ASM sera si el valor ya lo lei por I2C y esta en el registro 0x0c
btfsc 0x0c,7
pero en ccs estoy casi nuevo
"La curiosidad mato al gato, pero murio sabiendo"

Desconectado MLO__

  • Colaborador
  • DsPIC33
  • *****
  • Mensajes: 4581
Re: registros en DS1307en ccs
« Respuesta #1 en: 25 de Junio de 2009, 00:03:29 »
Hola.

Para eso estan las funciones: bit_test(var,bit)

Citar
Tests the specified bit (0-7,0-15 or 0-31) in the given variable.   
The least significant bit is 0.   
This function is much more efficient than, but otherwise similar to: ((var & (1<<bit)) != 0)

Código: C#
  1. if( bit_test(x,3) || !bit_test (x,1) ){
  2.          //either bit 3 is 1 or bit 1 is 0
  3.  
  4. }
  5.  
  6.  
  7. if(data!=0)
  8.   for(i=31;!bit_test(data, i);i--) ;
  9. // i now has the most significant bit in data
  10. // that is set to a 1

Saludos
El papel lo aguanta todo