Hi everyone
I want to launch a DS1307 with stm32f0 ,and I used this code's , but it doesn't work.
Someone know what the problem it??
I2C_HandleTypeDef hi2c1;
DMA_HandleTypeDef hdma_i2c1_rx;
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_DMA_Init(void);
static void MX_I2C1_Init(void);
static uint8_t ds_rbuf[8];
char txt_buf[10];
int main(void)
{
MX_GPIO_Init();
MX_DMA_Init();
MX_I2C1_Init();
/* USER CODE BEGIN 2 */
uint8_t ds_tbuf[8]={0};
HAL_I2C_Master_Transmit(&hi2c1,0xd0,ds_tbuf,8,100);
lcd_initilize();
HAL_I2C_Master_Receive_DMA(&hi2c1,0xd1,ds_rbuf,8);
/* USER CODE END 2 */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
lcd_gotoxy(0,0);
sprintf(txt_buf,"%02d",ds_rbuf[0]);
lcd_puts(txt_buf);
}
}
/* USER CODE BEGIN 4 */
void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef *hi2c)
{
/* Prevent unused argument(s) compilation warning */
UNUSED(hi2c);
/* NOTE : This function should not be modified, when the callback is needed,
the HAL_I2C_MasterRxCpltCallback could be implemented in the user file
*/
HAL_I2C_Master_Receive_DMA(&hi2c1,0xd1,ds_rbuf,8);
}
/* USER CODE END 4 */