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

problem in spi

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



Joined: 24 Jun 2011
Posts: 23
Location: INDIA

View user's profile Send private message Send e-mail

problem in spi
PostPosted: Fri Jun 24, 2011 11:42 pm     Reply with quote

hai,

I have a misunderstanding in SPI_L_TO_H & SPI_XMIT_L_TO_H. I don't know what is the difference between these two. That is, what does the spi_ mean and also what does the spi_xmit_ mean.......... pls anyone help me.
Ttelmah



Joined: 11 Mar 2010
Posts: 19554

View user's profile Send private message

PostPosted: Sat Jun 25, 2011 2:15 am     Reply with quote

1) Use the Mode definitions instead:
Code:

#define SPI_MODE_0  (SPI_L_TO_H | SPI_XMIT_L_TO_H)
#define SPI_MODE_1  (SPI_L_TO_H)
#define SPI_MODE_2  (SPI_H_TO_L)
#define SPI_MODE_3  (SPI_H_TO_L | SPI_XMIT_L_TO_H)

Then you can just use the standard 'mode' numbers, and are far less likely to have problems.

2) Data sheet is your friend. These two defines control the CKE, and CKP bits. CKE, controls where the data _transmission_ occurs relative to the clock edge. Then CKP, controls whether the clock sits 'high', and the active edge is the falling edge (SPI_H_TO_L), or whether the clock sits 'low', and the active edge is the rising one (SPI_L_TO_H).

Have a look at the WikiPedia article on SPI:
<http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus>

Then 'CPOL', is the CKP bit (clock polarity), and CKE is the CPHA bit.

Best Wishes
sreejith.s.s



Joined: 24 Jun 2011
Posts: 23
Location: INDIA

View user's profile Send private message Send e-mail

Re: problem in spi
PostPosted: Mon Jun 27, 2011 4:37 am     Reply with quote

Hi
Mr. Ttelmah

It was very helpful to me, thank you very much. But I am still not having a good idea about the difference between the normal SPI_L_to_H
AND SPI_XMIT_L_TO_H and why these two are used in a same mode?
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Mon Jun 27, 2011 5:39 am     Reply with quote

To configure SPI you always have to configure two settings:
1) Clock Polarity: The clock level when inactive
2) Clock Phase: At which clock edge the data is to be clocked in.

Freescale (Motorola) uses the names CPOL and CPHA.
For copyright reasons Microchip uses other names: CKP and CKE.
For unknown reasons CCS decided to use none of the above names and invented SPI_L_TO_H, SPI_H_TO_L and SPI_XMIT_L_TO_H.

Two configuration bits give a total of four combinations, for easier speaking often referred to as the four SPI-modes 0 to 3.

SPI parameter number 1 is easy to understand: Look at the clock level in inactive state, high or low, and that is your setting for CPOL/CKP/SPI_L_TO_H.

SPI parameter number 2 generates confusion because it is implemented in different ways:
- Freescale defines it as 'data is clocked in on the first edge (0) or second edge (1).
- Microchip defines it as 'data is clocked in on the first edge (1) or second edge (0).
- CCS defines it as 'data is clocked in on the positive edge (SPI_XMIT_L_TO_H) or negative edge (default)

In the table below you can see how all names relate to each other:
Code:
// SPI Mode | MOTOROLA | MICROCHIP | CCS                          | Data clocked in at
//----------------------------------------------------------------|-------------------
//          | CPOL CPHA|  CKP CKE  |                              |
//    0     |  0    0  |   0   1   | SPI_L_TO_H | SPI_XMIT_L_TO_H | low to high edge
//    1     |  0    1  |   0   0   | SPI_L_TO_H                   | high to low edge
//    2     |  1    0  |   1   1   | SPI_H_TO_L                   | high to low edge
//    3     |  1    1  |   1   0   | SPI_H_TO_L | SPI_XMIT_L_TO_H | low to high edge

Quote:
But I am still not having a good idea about the difference between the normal SPI_L_to_H AND SPI_XMIT_L_TO_H and why these two are used in a same mode?
As explained above for SPI you always have to define two parameters.
sreejith.s.s



Joined: 24 Jun 2011
Posts: 23
Location: INDIA

View user's profile Send private message Send e-mail

Thanks a lot !
PostPosted: Mon Jun 27, 2011 10:19 pm     Reply with quote

Now its seems to be very clear for me Idea thanks partners ! Razz
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