SparkFun Forums 

Where electronics enthusiasts find answers.

General project discussion / help
Did you make a robotic coffee pot which implements HTCPCP and decafs unauthorized users? Show it off here!
By freeter
#196013
About the single-chip microcomputer, I used http://www.kynix.com/Detail/265161/C8051F340.html, and the P0 port was set to be the output drain opening (SDA, SCL was connected to the pull resistance to 3.3 V).

Pin definitions are as follows:

sbit SDA = P0^6; //SDA ON P0.6
sbit SCL = P0^7; //SCL ON P0.7

The main program is as follow:

temp=0xa0;
while(1) //
{
temp<<=1;
SDA=CY;
NOP4();
SCL=1;
NOP4();
SCL=0;
//}

The SCL was normal in the measurement, but the waveform of SDA was always in low power.

Has anyone met this before? Need your help,please...
User avatar
By phalanx
#196031
I'm not well versed in 8051 microcontrollers but I did just skim the datasheet of the part you are using so take what I say with a grain of salt.

It appears you are trying to bit-bang I2C. Is there any particular reason why you aren't using the hardware SMBUS module in the microcontroller?

Have you verified that your port direction, port skip, and crossbar registers are all configured properly?

What is the instruction "SDA=CY" doing in the context of your program?

When you say SCL was normal, does that mean you could toggle it high and low? Does "SDA was always in low power" mean that the pin was always pulled low?

-Bill