Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.
my plan is to send via the I2C bus data captured by an ultrasonic range finder to a development board fitted with a PIC 18F and an LCD and other périphiriques. j'implimente when my C code to read the value captured by the rangefinder nothing appears on the LCD. Enclosed you will find the source code used.
//Get the range
while(1)
{
I2C1_Init(40000);
I2C1_Start(void); // send start sequence
I2C1_Wr(0xE0); // SRF02 I2C address with R/W bit clear
I2C1_Wr(0x00); // SRF02 command register address
I2C1_Wr(0x51); // command to start ranging in cm
I2C1_Stop(); // send stop sequence
delay_ms(70); //delay for 70ms.
I2C1_Start(void); // send start sequence
I2C1_Wr(0xE0); // SRF02 I2C address with W bit clear
I2C1_Wr(0x02); // send internal adress of high byte.
I2C1_Wr(0x03); // send internal adress of low byte.
I2C1_Repeated_Start(void); // send a restart sequence
I2C1_Wr(0xE1); // SRF02 I2C address with R bit set
PORTB= I2C1_Rd(0u); // Read the data (NO acknowledge)
I2C1_Stop(); // send stop sequence
inttostr(reslt,text);
Lcd_Out(1,1,"la distance est : "); // Write text in first row
Lcd_Out(2,2,text); // Write text in second row
Lcd_Out(2,12,"cm");
Delay_ms(2000);
}
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.