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

Transmitting int16 value through i2c
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
snock



Joined: 10 Oct 2011
Posts: 24

View user's profile Send private message

PostPosted: Fri Aug 02, 2013 9:14 am     Reply with quote

Ok, great. I appreciate the help.

Here is the routine I am testing now:

Code:

// * I2C INTERRUPT HANDLER *****************************************************
#int_ssp
void i2c_handler(void) {
    int8 state, incoming;
    state=i2c_isr_state();
    if(state<0x80) { // Master is sending data
       incoming = i2c_read(1);
       if(state==1) mem_addr=incoming; // Store the address
       if(state==2) card_data[mem_addr]=incoming; // Read and store the data
    }
    if(state>=0x80) { // Master is requesting data
       i2c_write(card_data[mem_addr]);  // Write the memory over i2c
    }
}
// *****************************************************************************       
jeremiah



Joined: 20 Jul 2010
Posts: 1371

View user's profile Send private message

PostPosted: Fri Aug 02, 2013 9:41 am     Reply with quote

One thing to note on #use i2c(). At some point in the early 4.100's, they swapped to 7bit addressing for the address parameter. They did switch back to 8bit addressing later on, but I dont' remember which versions were affected. You might try changing the address in your #use i2c() to 7 bit format for the 4.124 version and see if that works. If not, make sure to swap back to 8bit so you don't forget.
muhibraza1



Joined: 26 Jul 2013
Posts: 23

View user's profile Send private message

PostPosted: Mon Aug 05, 2013 6:48 am     Reply with quote

I am thankful to all of you for your valuable comments. the errata thing was the actual problem. It wasted so many days.
After ticking the Dont Do BSR15, I can see the system is not hanging at least. Now I am making tweaks and trying to understand the basic i2c communication.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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