CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

MTCH112

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
JCS83



Joined: 23 Sep 2015
Posts: 1

View user's profile Send private message

MTCH112
PostPosted: Wed Sep 23, 2015 7:59 am     Reply with quote

Hi everyone,

Has anyone here ever worked at the MTCH112 (mTouch chip). I'm having some problems with the read memory command. Someone for discuss about?

Thanks.
Ttelmah



Joined: 11 Mar 2010
Posts: 19549

View user's profile Send private message

PostPosted: Wed Sep 23, 2015 11:32 am     Reply with quote

What's your problem?.
It is fairly standard I2C, except for the checksum:
Code:

#define CHIP_ADDRESS 0xE6
#define READ 1

int1 read_registers(int8 start_register,char * buffer, int8 count)
{
     int8 csum=0;

     i2c_start();
     i2c_write(CHIP_ADDRESS);
     i2c_write(start_register);
     i2c_start();//repeated start
     i2c_write(CHIP_ADDRESS | READ); //read
     
     while(count--)
     {
         *buffer=i2c_read();
         csum ^= *buffer;
         buffer++;
     } //note chip does not require a NACK
     i2c_stop();
     i2c_start();
     i2c_write(CHIP_ADDRESS | READ); //now read checksum
     csum ^= i2c_read();
     i2c_stop();
     return csum; //returns 0 if checksum OK
}


This transfers 'count' bytes into the buffer, starting at 'start_register', and returns 0 if the checksum matches.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group