2016-06-28 08:14 AM
Hallo,
Leider komme ich noch nicht so ganz mit dem lesen von I2C Slaves klar. Das schreiben klappt. Hat jemand eine funktionierende Routine womit ich das lesen mal testen könnte? Im Internet finde ich zwar vieles, nichts funktioniert so wirklich :'( Hiermit schreibe ich Daten: uint8_t I2C_WrReg(I2C_TypeDef *I2Cx, uint8_t Addr, uint8_t Reg, uint8_t Val) { uint32_t tme_out = 0; while(I2C_GetFlagStatus(I2Cx, I2C_FLAG_BUSY) == SET) { if(tme_out++ > 800000) { tme_out = 0; return ERROR; } } I2C_TransferHandling(I2Cx, Addr, 1, I2C_Reload_Mode, I2C_Generate_Start_Write); while(I2C_GetFlagStatus(I2Cx, I2C_FLAG_TXIS) == RESET) { if(tme_out++ > 800000) { tme_out = 0; return ERROR; } } I2C_SendData(I2Cx, Reg); while(I2C_GetFlagStatus(I2Cx, I2C_FLAG_TCR) == RESET) { if(tme_out++ > 800000) { tme_out = 0; return ERROR; } } I2C_TransferHandling(I2Cx, Addr, 1, I2C_AutoEnd_Mode, I2C_No_StartStop); while(I2C_GetFlagStatus(I2Cx, I2C_FLAG_TXIS) == RESET) { if(tme_out++ > 800000) { tme_out = 0; return ERROR; } } I2C_SendData(I2Cx, Val); while(I2C_GetFlagStatus(I2Cx, I2C_FLAG_STOPF) == RESET) { if(tme_out++ > 800000) { tme_out = 0; return ERROR; } } I2C_ClearFlag(I2Cx, I2C_FLAG_STOPF); return SUCCESS; }2016-06-29 03:35 AM
Hi homann.jan,
Please use English (to be more understandable) in your post.Have a look to these examples under the it may be helpful. stm32f0_stdperiph_lib\STM32F0xx_StdPeriph_Lib_V1.5.0\Projects\STM32F0xx_StdPeriph_Examples\I2C-Syrine-