| ??? 01/14/06 05:45 Read: times |
#107379 - Bit Bangin Works fine. Responding to: ???'s previous message |
Dear friends,
I wrote a small routine that does read this ADC with bit banging instead of Hardware I2C. Suprisingly it works fine. I glow leds and keep them on if any error occurs diffrent leds for diffrent errors but no errors at all even after running for hours. here is bit banged routine.
// Returns 1 if error occured parameters pointer to buffer
// for storing adc value and adc channel no.
bit read_pcf8591( uchar *adrdbuff, uchar adch)
{
bit error; // bit to store error.
A24i2c_start(); // send start condition.
error=A24i2c_out(0x90); // send device address + write.
if (error) // If nack received lit up a led.
digdata[5]&=L_SCH;
error=A24i2c_out(adch); // send adc channel no.
if (error)
digdata[5]&=L_PROG; // if nack recd lit up led.
error=A24i2c_stop(); // send stop condition.
if (error) // If error occurs lit up a led
digdata[5]&=L_REPEAT;
A24i2c_start(); // send start condition.
error=A24i2c_out(0x91); // send device address + read
if (error) // If nack recd lit up led.
digdata[5]&=L_SCH;
*adrdbuff=A24i2c_in(0); // Read value from adc send ack.
*adrdbuff=A24i2c_in(1); // Read value froma adc send nack.
error=A24i2c_stop(); // send stop condition.
if (error) // if error occurs lit up led.
digdata[5]&=L_REPEAT;
return bit; // return error to main prog.
}
Please help me above software i2c routines works fine. Thanks & Regards, Prahlad Purohit |
| Topic | Author | Date |
| I2C routine getting stuck. | 01/01/70 00:00 | |
| you can get working code by using | 01/01/70 00:00 | |
| Re: Getting code working | 01/01/70 00:00 | |
| I took aquick look at the I2con use and | 01/01/70 00:00 | |
| Re: Why not interrupt. | 01/01/70 00:00 | |
| 24MHz without four layer board? | 01/01/70 00:00 | |
| Re: 24MHz | 01/01/70 00:00 | |
| What max freq can be used with two layer | 01/01/70 00:00 | |
| who knows | 01/01/70 00:00 | |
| I2C routine getting stuck. | 01/01/70 00:00 | |
| Working very well with C668 @ 94khz bus | 01/01/70 00:00 | |
| Bit Bangin Works fine. | 01/01/70 00:00 | |
| Problem Solved. | 01/01/70 00:00 | |
| maybe worth putting it into code library | 01/01/70 00:00 | |
Uploaded into code library. | 01/01/70 00:00 |



