cfernandez
Joined: 18 Oct 2003 Posts: 145
|
DS8007 Help |
Posted: Tue Jun 16, 2009 11:04 pm |
|
|
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, |
|