STMS005K6T6 如何采集内部参考电压。
stm8s003 adc中断和通道切换的问题
adc施密特触发器stm8
stm8l051f3 TSSOP20 封装,待机模式下,2天后,电流突然增加到140UA
STM8S用STVP烧录怎么加密?
如何使用ST官网例程_LIN总线通讯_STM8AF
STM8 LIN
IAR代码编辑太费劲了,想问一下有没有好的方法,试了VScode但是头文件老是报错,调了很久也没调好,想换个方法了。
想问一下各位大佬,IAR下载调试代码时出现 warning: is an illegal data sample expression IAR是什么意思啊?
STM8S标准库TIM1编码器功能不计数,请大师帮我看看
RE:STM8S硬件I2C读数据有问题
{
unsigned char temp;
numb=NumByteToRead;
/* While the bus is busy */
//while(I2C_GetFlagStatus(I2C_FLAG_BUSBUSY));
while(I2C_SR3 & 0x02); //总线空闲
/* Generate start & wait event detection */
// I2C_GenerateSTART(ENABLE);
I2C_CR2 |= 0x01; //产生起始位
/* Test on EV5 and clear it */
//while(!I2C_CheckEvent(I2C_EVENT_MASTER_MODE_SELECT));
while(!(I2C_SR1 & 0x01)); //起始位发送完成
/* Send slave Address in write direction & wait detection event */
// I2C_Send7bitAddress(EEPROM_ADDRESS, I2C_DIRECTION_TX);
I2C_DR = EEPROM_ADDRESS;
place=1;
//while(!I2C_GetFlagStatus(I2C_FLAG_ADDRESSSENTMATCHED));
//I2C_ClearFlag(I2C_FLAG_ADDRESSSENTMATCHED);
while(!(I2C_SR1&0x02));
temp = I2C_SR1;
temp = I2C_SR3;
place=2;
/* Test on EV6 and clear it */
//while(!I2C_CheckEvent(I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED));
//I2C_ClearFlag(I2C_FLAG_ADDRESSSENTMATCHED);
/* Send Address of first byte to be read & wait event detection */
// I2C_SendData((u8)(ReadAddr >> 8)); /* MSB */
I2C_DR = ((u8)(ReadAddr >> 8));
/* Test on EV8 and clear it */
// while (!I2C_CheckEvent(I2C_EVENT_MASTER_BYTE_TRANSMITTED));
while(!(I2C_SR1 & 0x84));
// I2C_SendData((u8)(ReadAddr)); /* LSB */
I2C_DR = ((u8)(ReadAddr));
/* Test on EV8 and clear it */
// while (!I2C_CheckEvent(I2C_EVENT_MASTER_BYTE_TRANSMITTED));
while(!(I2C_SR1 & 0x84));
/* Send STRAT condition a second time */
// I2C_GenerateSTART(ENABLE);
I2C_CR2 |= 0x01; //产生起始位
/* Test on EV5 and clear it */
// while(!I2C_CheckEvent(I2C_EVENT_MASTER_MODE_SELECT));
while(!(I2C_SR1 & 0x01)); //起始位发送完成
/* Send slave Address in read direction & wait event */
// I2C_Send7bitAddress(EEPROM_ADDRESS, I2C_DIRECTION_RX);
I2C_DR = EEPROM_READ_ADDRESS;
//while(!I2C_GetFlagStatus(I2C_FLAG_ADDRESSSENTMATCHED));
//I2C_ClearFlag(I2C_FLAG_ADDRESSSENTMATCHED);
while(!(I2C_SR1&0x02));
temp = I2C_SR1;
temp = I2C_SR3;
/* Test on EV6 and clear it */
// while(!I2C_CheckEvent(I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED));
//I2C_ClearFlag(I2C_FLAG_ADDRESSSENTMATCHED);
/* While there is data to be read */
while(NumByteToRead)
{
numb=NumByteToRead;
if(NumByteToRead == 1)
{
numb=NumByteToRead;
NumByteToRead--;
/* Disable Acknowledgement */
//I2C_AcknowledgeConfig(I2C_ACK_NONE);
I2C_CR2 &=~0x04;
/* Send STOP Condition */
//I2C_GenerateSTOP(ENABLE);
I2C_CR2 |=0x02;
I2C_CR2 &=0xf7;
while(!(I2C_SR1&0x40));
*pBuffer = I2C_DR;
I2C_CR2 |=0x04;
}
//* Test on EV7 and clear it */
//if(I2C_CheckEvent(I2C_EVENT_MASTER_BYTE_RECEIVED))
if(NumByteToRead > 1)
{
//I2C_CR2 |=0x04;
I2C_CR2 &=0xfd;
I2C_CR2 |=0x08;
/* Read a byte from the EEPROM */
//*pBuffer = I2C_ReceiveData();
while(!(I2C_SR1&0x40));
temp = I2C_SR1;
*pBuffer = I2C_DR;
I2C_CR2 |=0x04;
/* Point to the next location where the byte read will be saved */
pBuffer++;
/* Decrement the read bytes counter */
NumByteToRead--;
}
RE:STM8S硬件I2C读数据有问题
回复:STM8S硬件I2C读数据有问题
RE:STM8S硬件I2C读数据有问题
I2C_CR2 &=0xfd;I2C_CR2 &= ~0x08;,结帖