TODOPIC

Microcontroladores PIC => Lenguaje C para microcontroladores PIC => Mensaje iniciado por: allennet en 24 de Junio de 2009, 23:41:15

Título: registros en DS1307en ccs
Publicado por: allennet 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
(http://www.caveo.com.ar/Doc%20Tecnica/Hard%20Perif/regist2.gif)
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
Título: Re: registros en DS1307en ccs
Publicado por: MLO__ 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