BreederBai wrote:Giovanni wrote:Are I2C pins programmed in the right way? do you have external pull up resistors? there are several possible causes for the I2C to hang, how you call that function is not very important.
Giovanni
Hello, I am using PB6, 7 pins, configured as ‘Alternate Open Drain output 2MHz’ Mode, initial level is high.Code: Select all
#define VAL_GPIOBCRL 0xEE222888
#define VAL_GPIOBCRH 0x88488A48
#define VAL_GPIOBODR ((1 << 6) | (1 << 7))
The submission number of the ChibiOS I am using is 7d187a140e64db297eb5ef788f0f5dc0dd0d3fde, November 21, 2016 4:52 PM.
I have an external pull-up resistor and the pull-up resistor is 1K.
This make it look as if you are manually writing to the CPIO registers, rather than using Chibi's capabilities.
Have you configured the relevant alternate function number? (I've not used the 32F1XX family, but on the 32F4XX, which has the same I2C peripheral, its AF4).
It also looks as if you might be using a relatively old version of ChibiOs (although the I2C has worked fine for years).
You can generally set up the initial mode etc for I/O pins in the board configuration file; then you just need to do i2cstart().