/*
	MGDSRAM.C

	BL14xx/MicroG or BL15xx/MicroG2

   Write and read to the ram space of the DS1302 chip. Note that since the
   MicroG is not battery backed, the ram data are lost when power is gone.

   To preserve data in the DS1302 ram, as well as the time data on the
   on the DS1302 connect a large cap or a rechargeble battery on VBAT.
   The DS1302 can be programmed to trickle charge the battery or the large
   capacitor. See the program MGCHRGER.C for an example.
*/

main()
{
char test[31];
char test2[31];
int i,j,k;

   hitwd();

   printf("Writing data to the DS1302 ram area.\n");
   for(i=0;i<=30;i++)
   {
      WriteRam1302(i,i);
   }

   hitwd();
   printf("Reading data back from the DS1302 ram area.\n");
   for(i=0;i<=30;i++)
   {
      printf("DS1302 RAM[%d] = %d\n", i, ReadRam1302(i));
      hitwd();
   }

   for(i=0;i<=30;i++)
   {
      test[i] = 0x40 + i;
      test2[i] = 0x00;
   }

   hitwd();
   printf("Writing data to DS1302 in burst mode.\n");
   WriteBurst1302(test, 31);

   hitwd();
   printf("Reading back DS1302 ram data in burst mode.\n");
   ReadBurst1302(test2, 31);

   for(i=0;i<=30;i++)
   {
      printf("DS1302 RAM[%d] = %d\n", i, test2[i]);
      hitwd();
   }

   printf("\n\nTry reading and writing to the DS1302 thru the watch window.\n");
   while(1)
   {
      hitwd();
      runwatch();
   }
}
