用了原子的例程 改了引脚不能驱动24c256
怀疑是硬件问题,换了一个256 128 都不能驱动
下面是代码
myiic.h
#define SDA_IN() {GPIOG->MODER&=~(3<<(7*2));GPIOB->MODER|=0<<7*2;} //PB9&Ecirc;&auml;&Egrave;&euml;&Auml;&pound;&Ecirc;&frac12;
#define SDA_OUT() {GPIOG->MODER&=~(3<<(7*2));GPIOB->MODER|=1<<7*2;} //PB9&Ecirc;&auml;&sup3;&ouml;&Auml;&pound;&Ecirc;&frac12;
#define IIC_SCL PGout(6) //SCL
#define IIC_SDA PGout(7) //SDA
#define READ_SDA PGin(7) //&Ecirc;&auml;&Egrave;&euml;SDA
.C
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);//&Ecirc;&sup1;&Auml;&Uuml;GPIOB&Ecirc;±&Ouml;&Oacute;
//GPIOB8,B9&sup3;&otilde;&Ecirc;&frac14;&raquo;&macr;&Eacute;è&Ouml;&Atilde;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;//&AElig;&Otilde;&Iacute;¨&Ecirc;&auml;&sup3;&ouml;&Auml;&pound;&Ecirc;&frac12;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//&Iacute;&AElig;&Iacute;ì&Ecirc;&auml;&sup3;&ouml;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;//100MHz
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;//&Eacute;&Iuml;&Agrave;
GPIO_Init(GPIOB, &GPIO_InitStructure);//&sup3;&otilde;&Ecirc;&frac14;&raquo;&macr;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;//SDA
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;//&AElig;&Otilde;&Iacute;¨&Ecirc;&auml;&sup3;&ouml;&Auml;&pound;&Ecirc;&frac12;
GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;//&iquest;&ordf;&Acirc;&copy;&Ecirc;&auml;&sup3;&ouml;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;//100MHz
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;//&Eacute;&Iuml;&Agrave;
GPIO_Init(GPIOB, &GPIO_InitStructure);//&sup3;&otilde;&Ecirc;&frac14;&raquo;&macr;
看了一个帖子把SDA改成开漏可以,但是我还是不行
main里面把24c02的检测注释掉了 |