feng tian

Xs128 MCU simulation iic communication acquisition mma7455 no response signal

Discussion created by feng tian on Dec 11, 2011
Latest reply on Dec 11, 2011 by feng tian
void start() {SDA=1;delay1us();SCL=1;delay1us();SDA=0;delay1us();SCL=0;}void end(){SDA=0;delay1us();SCL=1;delay1us();SDA=1;delay1us();}void respons(){uchar i;SCL=1;delay1us();outa=0;delay1us();while((SDA==1)&&(i<250))i++;SCL=0;delay1us();outa=1;delay1us();}void write_byte(uchar date){uchar i;for(i=0;i<8;i++){SCL=0;delay1us();if(date&0x80) SDA=1;else SDA=0;delay1us();SCL=1;delay1us();date<<=1; }SCL=0;delay1us();SDA=1;delay1us();}uchar read_byte(){ uchar i,k; SCL=0; delay1us(); SDA=1; delay1us(); outa=0; delay1us(); for(i=0;i<8;i++) {  SCL=1;  delay1us();  k=(k<<1)|SDA;  SCL=0;  delay1us(); } outa=1; return (k);}    void write_add(uchar add,uchar date)  {   start();   write_byte(0x3a);   respons();   write_byte(add);   respons();   write_byte(date);   respons();   end();   }    uchar read_add(uchar add)    {     uchar date;     start();     write_byte(0x3a);     respons();     write_byte(add);     respons();     start();     write_byte(0x3b);     respons();     date=read_byte();     respons();     end();     return (date);    }

 outa is DDRT_DDRT1


My English is not good, so I can explain about meaning, hope to understand; My program in C51 MCU can be run, but in XS128 has been no response signal

    by tian feng