In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Alessandro wrote: This is my MAIN (the rest of VP in not changed appart for the slaveid and the isr_period) I need to Send the byte in this order (1° slaveid, address of memory, $03, and then i need to read the result of a distance misure by Lego Ultrasonic Sensor. Can anybody help? or send me the routin in SXB? main _bank I2CM mov I2CM_address,#slave_adr ; set address of slave to read. _bank VARS ; clear read and write pointers clr read_adr clr write_ptr mov read_adr,#$42 I2C_read _bank VARS mov w,read_adr _bank I2CM mov I2CM_data_0,w ; load send register with data address call @I2CM_wait_not_busy ; wait for I2CM state machine to enter idle state call @I2CM_send_byte ; send 'want to read' and bank addess to i2c slave call @I2CM_wait_not_busy ; wait for I2CM state machine to enter idle state call @I2CM_get_byte ; Gets the byte from slave and returns it in w snb I2CM_NACK jmp got_NACK ; indicate no NACK by entering never ending loop test w ; check for null character read ;jz main ; null char, end of string...restart ;mov recv_char,w ; save received character ;cjne recv_char,#'S',bad_data ; used to confirm valid recieved matches stored data Thanks a lot. Alessandro (Italy) ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=261473#m261674 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2008 (http://www.dotNetBB.com)