vinay shabad
Junior Member level 3

hiii i am writing program for communication betwwen i2C and SHT21 sensor i have found some example code with the help of that i wrote mine but it is having some errors
void I2c_init ()
//Ready
I2C> W //<<< Set 3.3v power supply on
Power supplies ON
I2C> (1) // <<< Search device on I2C bus//Searching I2C address space. Found devices at:
0x80(0x40 W) //<<< SHT21 is found
I2C> [0x80 0xE3][0x81 %:1000 r:3] // <<< start measure temperature and read value
I2C START BIT
WRITE: 0x80 ACK
WRITE: 0xE3 ACK
I2C STOP BIT
I2C START BIT
WRITE: 0x81 ACK
DELAY 1000ms
READ: 0x59 ACK 0x4C ACK 0x64
NACK
I2C STOP BIT
I2C> [0x80 0xE5][0x81 [%:1000] r:3] //<<< start measure humidity and read value
I2C START BIT
WRITE: 0x80 ACK
WRITE: 0xE5 ACK
I2C STOP BIT
I2C START BIT
WRITE: 0x81 ACK
DELAY 1000ms
READ: 0x8B ACK 0x22 ACK 0xDD
NACK
I2C STOP BIT
I2C>
errors
rogram Files\Microchip\mplabc30\v3.25\support\peripheral_24F\i.c:10: error: syntax error before 'I2C'
C:\Program Files\Microchip\mplabc30\v3.25\support\peripheral_24F\i.c:14: error: stray '%:' in program
C:\Program Files\Microchip\mplabc30\v3.25\support\peripheral_24F\i.c:21:7: error: invalid suffix "ms" on integer constant
C:\Program Files\Microchip\mplabc30\v3.25\support\peripheral_24F\i.c:25: error: stray '%:' in program
C:\Program Files\Microchip\mplabc30\v3.25\support\peripheral_24F\i.c:32:7: error: invalid suffix "ms" on integer constant
C:\Program Files\Microchip\mplabc30\v3.25\support\peripheral_24F\i.c:36:5: warning: no newline at end of file
----------------------------------------------------------------------
can any one please help me i am not C language expert it would be appriciable if some one help.Thankyou in advance
void I2c_init ()
//Ready
I2C> W //<<< Set 3.3v power supply on
Power supplies ON
I2C> (1) // <<< Search device on I2C bus//Searching I2C address space. Found devices at:
0x80(0x40 W) //<<< SHT21 is found
I2C> [0x80 0xE3][0x81 %:1000 r:3] // <<< start measure temperature and read value
I2C START BIT
WRITE: 0x80 ACK
WRITE: 0xE3 ACK
I2C STOP BIT
I2C START BIT
WRITE: 0x81 ACK
DELAY 1000ms
READ: 0x59 ACK 0x4C ACK 0x64
NACK
I2C STOP BIT
I2C> [0x80 0xE5][0x81 [%:1000] r:3] //<<< start measure humidity and read value
I2C START BIT
WRITE: 0x80 ACK
WRITE: 0xE5 ACK
I2C STOP BIT
I2C START BIT
WRITE: 0x81 ACK
DELAY 1000ms
READ: 0x8B ACK 0x22 ACK 0xDD
NACK
I2C STOP BIT
I2C>
errors
C:\Program Files\Microchip\mplabc30\v3.25\support\peripheral_24F\i.c:14: error: stray '%:' in program
C:\Program Files\Microchip\mplabc30\v3.25\support\peripheral_24F\i.c:21:7: error: invalid suffix "ms" on integer constant
C:\Program Files\Microchip\mplabc30\v3.25\support\peripheral_24F\i.c:25: error: stray '%:' in program
C:\Program Files\Microchip\mplabc30\v3.25\support\peripheral_24F\i.c:32:7: error: invalid suffix "ms" on integer constant
C:\Program Files\Microchip\mplabc30\v3.25\support\peripheral_24F\i.c:36:5: warning: no newline at end of file
----------------------------------------------------------------------
can any one please help me i am not C language expert it would be appriciable if some one help.Thankyou in advance