#include "stm32f10x.h"
int main(void)
{
SystemInit();// clock
RCC->APB2ENR|=1<<14; //enable usart1
RCC->APB2ENR|=1<<2; //enable gpioa
RCC->APB1ENR|=1<<21; //enable iic
RCC->APB2ENR|=1<<3; //enable gpiob
GPIOA->CRH|=0X000008B0;
GPIOB->CRL|=0Xff000000;
USART1->SR|=1<<13;
USART1->BRR=0X1D4A;
RCC->APB1RSTR |= 1<<21;
RCC->APB1RSTR &= ~(1<<21);
I2C1->CR2|=8;
I2C1->CCR|=4;
I2C1->TRISE|=9;
I2C1->CR1|=(1<<10+1<<6);
I2C1->CR2|=1<<10;
I2C1->CR2|=1<<9;
I2C1->CR2|=1<<8;
I2C1->OAR1|=1<<14;
I2C1->CR1|=1;
while(1)
{
I2C1->CR1|=1<<8; //start
while(!(I2C1->SR1&1)) //start sb
{}
I2C1->DR=0XA0; //write address
while(!(I2C1 -> SR1&2))
{}
I2C1->DR=0XA0;
}
}
没有中断 |