CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

DS8007 Help

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
cfernandez



Joined: 18 Oct 2003
Posts: 145

View user's profile Send private message

DS8007 Help
PostPosted: Tue Jun 16, 2009 11:04 pm     Reply with quote

hi,

I want to use this IC with a 18F8722, I want use parallel Multiplexed mode and my question is if exist somebody that can help me with the read and write function.

This is the PDF - http://datasheets.maxim-ic.com/en/ds/DS8007.pdf

And this is the example code that work with a DS5002 (8051).

Code:

#pragma REGPARMS
uint8_t dssc_readregister(uint8_t address)
{
   idata uint8_t rAddress, toReturn;
#ifdef DEBUG_CRED
   idata uint8_t count = 0;
#endif
   rAddress = address;

   //ds5250 DMOS |= 0x01;
   RPCTL |= 0x20;
   P1 &= 0xEF;        // Happy CS for DS8007 on Eval Refrence Design
   switch (rAddress)
   {
    case URR:
      // If reading URR, check the CRED bit in MSR so that
      // we don't overrun the DS8007.  See MSR.CRED bit description on page
      // 18 of DS8007 spec.
#ifdef DEBUG_CRED
      while (!(BASE_ADDRESS[MSR] & MSR_CRED_MASK))
      {
           // If card de-powers exit with zero return value.
           if ((BASE_ADDRESS[PCR] & 0x01) == 0)
         {
            //ds5250 DMOS &= 0xFE;
            P1 |= 0x10;        // Happy CS for DS8007 on Eval Refrence Design

            RPCTL &= 0xDF;
              return 0;
         }

         count++;
         if (count == 30000)
         {
            printf("CRED read locked up on: %02bx\n",rAddress);
            printf("PCR: %02bx\n",BASE_ADDRESS[PCR]);
            printf("HSR: %02bx\n",BASE_ADDRESS[HSR]);
            count = 0;
         }
      }
#else
      while (!(BASE_ADDRESS[MSR] & MSR_CRED_MASK))
      {
         // If card de-powers exit with zero return value.
         if ((BASE_ADDRESS[PCR] & 0x01) == 0)
           {
            //ds5250 DMOS &= 0xFE;
            P1 |= 0x10;        // Happy CS for DS8007 on Eval Refrence Design

            RPCTL &= 0xDF;
                return 0;
         }
      }
#endif
         break;
      default:
         break;
   }

   toReturn = BASE_ADDRESS[rAddress];
   //ds5250 DMOS &= 0xFE;
   P1 |= 0x10;        // Happy CS for DS8007 on Eval Refrence Design

     RPCTL &= 0xDF;
   return toReturn;

}

void dssc_writeregister(uint8_t address,uint8_t value)
{
   idata uint8_t rAddress, rValue ;
#ifdef DEBUG_CRED
     idata int count = 0;
#endif
   rAddress = address;
   rValue = value;

   //ds5250 DMOS |= 0x01;
     RPCTL |= 0x20;
   P1 &= 0xEF;        // Happy CS for DS8007 on Eval Refrence Design
     switch (rAddress)
     {
   case TOC:
    case UTR:
      // If writing TOC or UTR, check the CRED bit in MSR so that
      // we don't overrun the DS8007.  See MSR.CRED bit description on page
      // 18 of DS8007 spec.
#ifdef DEBUG_CRED
      while (!(BASE_ADDRESS[MSR] & MSR_CRED_MASK))
      {
         // If card de-powers exit with zero return value.
           if ((BASE_ADDRESS[PCR] & 0x01) == 0)
           {
            //ds5250 DMOS &= 0xFE;
            P1 |= 0x10;        // Happy CS for DS8007 on Eval Refrence Design

            RPCTL &= 0xDF;
            return;
         }
           count++;
         if (count == 30000)
         {
            printf("CRED write locked up on: %02bx\n",rAddress);
            printf("PCR: %02bx\n",BASE_ADDRESS[PCR]);
            printf("HSR: %02bx\n",BASE_ADDRESS[HSR]);
            count = 0;
         }
      }
#else
      while (!(BASE_ADDRESS[MSR] & MSR_CRED_MASK));
#endif
      break;
       default:
            break;
   }
   BASE_ADDRESS[rAddress] = rValue;

   //ds5250 DMOS &= 0xFE;
   P1 |= 0x10;        // Happy CS for DS8007 on Eval Refrence Design
   RPCTL &= 0xDF;

}


My dude is if the ALE is necessary generate a continue pulse or only put in high and low depend the address or data? If is necessary, how to make this with the 18F8722 and CCS???

Thank you very much!

Best Regards,
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group