Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Why input not output?
I have used them as output and it is not working code is as per your post.
The brushless motor and driver can be tested by connecting GND to the SCL pin and applying a fixed analog voltage from 0V to 5V on the SDA pin using a 1kohm – 100kohm potentiometer. The driver will enter test mode on start-up if SCL is connected to GND and start the motor at a speed depending on the voltage on the SDA pin. This can be used to simply test the functionality of the motor driver and the brushless motor.
Here is the code.......
I2C_write(char x){
SSPBUF=x;
while(BF);
/* wait for any pending transfer */
while ( ( SSPCON2 & 0x1F ) || ( SSPSTAT & 0x04 ) );
}
void main(void){
TRISC3=0;
TRISC4=0;
__delay_ms(200);
I2C_init();
__delay_ms(50);
I2C_start();
I2C_write(0x12);
I2C_write(100);
I2C_STOP();
while(1){
}
}
I have tested the esc it is working as per manual but with uC it is not i2c seems to be wrong.
The ckt scl and sda is connected with 5k pull up and the esc 5v and 8v power supply.
But what is the problem with i2c?
And where to feed pwm scl or sda?
There is no ppm pin.
I think it doesn't even matter how you configure the pins because the I2C hardware handles the pins according to I2C specs anyway.
Edit: Why configure them as input and not output, if it does not matter? Well, input is safer (electrically) than output.
So what to do?
I've fallen into this misconception as well setting ports as output and wondering why the peripherals associated with that port aren't working.
If I remember rightly, setting the port as input allows the peripheral to have control (input and output) over that port. Setting it as an output often stops the peripheral working on that port.
If the datasheet says to do so, do it.
Yes. What I can't understand is:
1) The example code configured the ports as input
2) I said: "configure the ports as inputs.. follow the example code
3) Ritesh configured the ports as output