WEll, now the I2C is in operational mode, but still not working quite right.
The clock line doesnt seem to generate a clock for starters, im trying to send a start signal, then the adress, then repeated start, then adrress again, etc. this is what im getting on the scope, and my code: the code: GPIOB_CRH = 0x0000DD00;//I2C lines are AF output open drain RCC_APB1ENR = 0x00400000; //enable I2C2 clock RCC_APB2ENR = 0x0000000D; //enable PA,PB,AF clock I2C2_OAR1 = 0x00004000; //bit 14 should be kept 1 by software I2C2_CR2 = 0x00000008; //frequency 36 mHZ, //enable event interrupts I2C2_CCR = 0x00000028; //clock configure I2C2_TRISE) = 0x00000009; // Rise time I2C2_CR1 = 0x00000401; //Enable ACK, Enable I2C while (1) { I2C2_CR1 |=0x00000100; //send START while(I2C2_SR1<1); //wait till START is complete delay(1); *(uint32*)(I2C2_DR) = 0b10010010; //while( (I2C2_SR1 >>1) <1); <- wait till address has been sent. If I use that line, the code gets stuck, meaning this condition isnt fulfilled delay(10); } thanks again!
How fantastically ironic. Ok, what is your clock rate for the APB1? I'd guess from the settings 8 MHz, but your comments suggest 36 MHz, so which is it?
Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
hehe, by ''on my own'' I meant ''manually'', not alone, in the dark, without internet :) As for the clock rate, its 8 MHz, the comments for the I2C2_xxx registers are wrong for some reason. I took all the clock settings from the reference manual, it has an exapmle for setting the right clock rates for 100 kHz speed