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

how to use interrupts_SSP

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



Joined: 21 Sep 2005
Posts: 9

View user's profile Send private message

how to use interrupts_SSP
PostPosted: Sun Nov 20, 2005 6:24 pm     Reply with quote

hello everybody:

My question is the following one and this related with the interrupcion ssp:
i want to know how to use the interrupts_SSP??

first question:
When in the code of the master the instruction ( i2c_start) is executed, is it in this moment when all the slaves enter to the interrupcion ssp, else when is it??
after that ,the master tranfers the slave's address, this means that to all arrives them the address, but alone the one that has that address responds him the master???

the slave responds ACk ,when this the master begins the transmision.

second question:

the instruction (i2c_poll) returns TRUE when the slave receives the address or a data??

How to see us . i have a lot of doubts about i2c. therefore I need to help of you.

thanks

hqv
hqv



Joined: 21 Sep 2005
Posts: 9

View user's profile Send private message

someboby can help me with i2c
PostPosted: Sun Nov 20, 2005 10:25 pm     Reply with quote

hello:

i need to understand the i2c protocol, it is my first time with this protocol, therefore i have a lot of doubs about its operation.

i use ccs with mplab, that program doesn't have instruction i2c_isr_state();

thanks
hqv
hqv



Joined: 21 Sep 2005
Posts: 9

View user's profile Send private message

i have problem with the trasmision of data since the master
PostPosted: Mon Nov 21, 2005 12:01 am     Reply with quote

hi again:

Another problem that i have is to send more than one data since the master toward the slave.

I read the ccs's manual and I utilized its examples and not with himself that send more than one alone data, unless it this losing I.

how can i do for verify if I am sending well the data?

thanks

hqv
Ttelmah
Guest







PostPosted: Mon Nov 21, 2005 11:17 am     Reply with quote

The answer to most of the bits of your first post, is 'no'.
Interrupts are generated in the slave, for each byte transferred. The first interrupt on a transaction, is on an 'address match'. When this occurs, an interrupt is generated. The 'start', does not generate an interrupt, but tells the hardware to look at the next byte for a possible address.
The master does not wait for an 'ack', to start a transaction, but waits for it to go off, to _end_ a transaction.
Interrupts are subsequently generated for the completion of each byte being read, or each byte being sent, depending on the direction control bit that was included with the address. The hardware generates an '/ACK', for each byte. This line then raises, when data is transfered into, or out of the I/O buffer in the slave, to tell the master that the slave has accepted the byte (or sent a new one).
CCS, now supply a function, which returns the read/write bit, masked into it's top bit, and in the bits below this, a 'transfer counter', which increments for each transaction. Hence you can use this (with a suitable offset), to transfer bytes from multiple addresses.
A really crude extension of the 'example', for the slave interrupt handler, is shown below, to just allow two bytes to be received:
[code]
#INT_SSP
void ssp_interupt ()
{
BYTE incoming, state;
state = i2c_isr_state();
if(state < 0x80)
//Master is sending data
{
incoming = i2c_read(1);
if(state == 1) {
//First received byte -if you want to implement random access
//I/O, then send an 'address' here, and save this for future
//transactions.
I2C_VAL.b[0] = incoming;
}
if(state == 2) {
//Second received byte
I2C_VAL.b[1] = incoming;
//Set a flag to tell the 'main' that data has arrived
newval=true;
}
}
}

I suggest you look at the data sheet for your chip, and read the sections on the I2C transactions, and also ge the Philips notes on this.
The CCS code, and examples, assume that you already understand I2C.

Best Wishes
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