For what??
I guess you didn't read the rest of the sentence.
Mike.
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.
For what??
I guess you didn't read the rest of the sentence.
Mike.
I think you nailed the crux of the problem.
void I2C_start(void){
SEN=1;
while(SEN);
}
Should be this
void i2c_Start(void)
{
i2c_Wait();
SEN=1;
}
void I2cSTOP(void ){
PEN=1;
while(PEN);
}
void i2c_Stop(void)
{
i2c_Wait();
PEN=1;
}
void I2C_start(void){
SEN=1;
while(SEN);
}
Should be this
void i2c_Start(void)
{
i2c_Wait();
SEN=1;
}
void I2cSTOP(void ){
PEN=1;
while(PEN);
}
void i2c_Stop(void)
{
i2c_Wait();
PEN=1;
}
It hangs on the while loops he made.
Yep it is there a working sample code on page 8 if the op lookedAmazing.
Mike.
#include <htc.h>
__CONFIG(LVP_OFF & BOREN_OFF & PWRTE_ON & WDTE_OFF & FOSC_HS);
#define _XTAL_FREQ 20000000
#define SDATA RC4
#define SCLK RC3
void I2C_init(),I2C_start(void),I2C_write(char x), I2cSTOP(void);
void i2c_Wait(void);
void main(void){
TRISC3=1; //direction to input have be changed
TRISC4=1;
TRISC0=0;
TRISC1=0;
TRISC2=0;
RC0=0;
RC1=0;
RC2=0;
__delay_ms(500);
I2C_init();
__delay_ms(50);
I2C_start();
RC0=1;
I2C_write(0x12);//esc default addr
RC1=1;
I2C_write(100);//testing speed 0-255
RC2=1;
I2cSTOP();
while(1){
RC0=0;
RC1=0;
RC2=0;
__delay_ms(500);
RC0=1;
RC1=1;
RC2=1;
__delay_ms(500);
}
}
void I2C_init(void)
{
SSPCON = 0x38; // set I2C master mode
SSPCON2 = 0x00;
SSPADD = 0x0C; //400KHZ 20MHz xtal
SSPSTAT|=0X80;
PSPIF=0; // clear SSPIF interrupt flag
BCLIF=0; // clear bus collision flag
}
void I2C_start(void)
{
i2c_Wait();
SEN=1;
}
void I2C_write(char x){
i2c_Wait();
SSPBUF=x;
}
void i2c_Wait(void){
while((SSPCON2 & 0X1F || (SSPSTAT & 0X04)));
}
void I2cSTOP(void)
{
i2c_Wait();
PEN=1;
}
Lol it has a better chance now. But it would of made betterDoes it work?
Lol it has a better chance now. But it would of made better
Sense to have tried it and told if it works lol
That would be what most people would do.
I'm starting to believe RK is a possibly a bot.
Is this fine now?
Code:#include <htc.h> __CONFIG(LVP_OFF & BOREN_OFF & PWRTE_ON & WDTE_OFF & FOSC_HS); #define _XTAL_FREQ 20000000 #define SDATA RC4 #define SCLK RC3 void I2C_init(),I2C_start(void),I2C_write(char x), I2cSTOP(void); void i2c_Wait(void); void main(void){ TRISC3=1; //direction to input have be changed TRISC4=1; TRISC0=0; TRISC1=0; TRISC2=0; RC0=0; RC1=0; RC2=0; __delay_ms(500); I2C_init(); __delay_ms(50); I2C_start(); I2C_write(0x12);//esc default addr I2C_write(100);//testing speed 0-255 I2cSTOP(); while(1){ RC0=0; RC1=0; RC2=0; __delay_ms(500); RC0=1; RC1=1; RC2=1; __delay_ms(500); } } void I2C_init(void) { SSPCON = 0x38; // set I2C master mode SSPCON2 = 0x00; SSPADD = 0x0C; //400KHZ 20MHz xtal SSPSTAT|=0X80; PSPIF=0; // clear SSPIF interrupt flag BCLIF=0; // clear bus collision flag } void I2C_start(void) { i2c_Wait(); SEN=1; } void I2C_write(char x){ i2c_Wait(); SSPBUF=x; } void i2c_Wait(void){ while((SSPCON2 & 0X1F || (SSPSTAT & 0X04))); } void I2cSTOP(void) { i2c_Wait(); PEN=1; }