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 support@ccsinfo.com

SPI Timer2 CLK doesn't work if SPI_H_TO_L is set

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







SPI Timer2 CLK doesn't work if SPI_H_TO_L is set
PostPosted: Sat Feb 28, 2009 12:40 pm     Reply with quote

Hi,

I'm using a PIC18F24J10 and i need a max. 70kHz SPI Clock. The PIC have a 10MHZ ocsillator. So I decide to use the Timer2 as SPI Clock source. But that works only if the SPI is set to SPI_L_TO_H but not on SPI_H_TO_L. I am using 4.057.

Could anyone help me on my problem?

Thorsten
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Feb 28, 2009 4:54 pm     Reply with quote

What chip are you using as the SPI slave ? Normally, the data sheet
for the slave chip will specify the required SPI mode. The SPI mode will
be one of these four modes:
Code:
// SPI modes
#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)

Normally we prefer to use these constants for the SPI mode, instead
of using "SPI_L_TO_H", etc., because it's easier.

Post a link to the web page for the SPI slave chip.


There is an errata on using Timer2 as the source for the SPI clock
for some PICs. I don't see this bug listed on the errata sheet for
the 18F24J10, but it still could be present (but not admitted yet by
Microchip).
Thorsten
Guest







PostPosted: Sun Mar 01, 2009 1:08 am     Reply with quote

Hi,

i´m using a QT1106 Wheel IC. Please google for the Datasheet because i can´t post the link (GUEST Acount ) The SPI Mode must be Mode 3. Any more suggestions?

Thanks fpor help.

Thorsten
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Mar 01, 2009 1:51 am     Reply with quote

Here's the link to the web page.
http://www.qprox.com/products/Page-16067/qt1106.html

SCLK idles high and it samples on the rising edge. That's SPI mode 3:
http://www.totalphase.com/support/kb/10045/#modes
Are you using the following configuration for your setup_spi() statement ?
Code:
#define SPI_MODE_3  (SPI_H_TO_L | SPI_XMIT_L_TO_H)
Thorsten
Guest







PostPosted: Sun Mar 01, 2009 2:02 am     Reply with quote

Yes, i use this setting. I just tried it on a PIC18F87J10 with the same result.
I will try it now on a PIC16. I will inform you about the result.
Anymore Hints?

Greetings

Thorsten
Thorsten
Guest







PostPosted: Sun Mar 01, 2009 2:21 am     Reply with quote

On a PIC18F452 it works.
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