stm32和AT24C02的硬件IIC通訊起始信號發(fā)送以后從機不應答
源碼:
- #include "stm32f10x.h"
- #include "bsp_iic.h"
- #include "bsp_usart.h"
- #include "bsp_led.h"
- uint8_t temp_data[50];
- uint8_t temp_data_back[50];
- int IIC_Transmit_test(void);
- int main(void)
- {
- IIC_Init();
-
- USART_Config();
-
- LED_GPIO_Config();
- printf("開始接收");
- if(IIC_Transmit_test()== 1)
- {
- LED_RED;
- }
- else
- {
- LED_BLUE;
- }
- while(1)
- {
- }
- }
- //IIC數(shù)據(jù)傳輸檢測
- int IIC_Transmit_test(void)
- {
- uint8_t i=0;
-
- for(i=0;i<=10;i++)
- {
- temp_data[i]=i;
- printf("%x ",temp_data[i]);
- }
-
- IIC_Write_page_fast(temp_data,0x00,10);
- printf("寫入成功");
- IIC_Read_page(temp_data_back,0x00,10);
- printf("讀出的數(shù)據(jù)");
- for(i=0;i<=10;i++)
- {
- if(temp_data_back[i]==temp_data[i])
- {
- printf("%x ",temp_data_back[i]);
- }
- else
- {
- printf("通訊失敗");
- return 0;
- }
- }
- printf("讀寫測試成功");
- return 1;
- }
復制代碼
全部資料51hei下載地址:
MPU6050-1.7z
(181.4 KB, 下載次數(shù): 11)
2019-1-17 15:19 上傳
點擊文件名下載附件
|