Searching \ for '[PIC]: Using Timer 2 as clock for SPI?' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/ios.htm?key=spi
Search entire site for: 'Using Timer 2 as clock for SPI?'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: Using Timer 2 as clock for SPI?'
2003\02\06@043812 by Graham North

flavicon
face
Hi everyone,

How exactly do I use Timer 2 as the clock source for SPI? I am using a
17C756A, but guess it will be similar on other micros. Does the clock toggle
every time the timer 'ticks', or only when the timer rolls over and
generates an interupt? The data book does not describe it well.

I am trying to get an ~2.5MHz clock speed for my SPI link with a 20MHz xtal,
can it be done?

Thanks

Graham North

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\02\06@045924 by hael Rigby-Jones

picon face
> -----Original Message-----
> From: Graham North [SMTP:spam_OUTgraham.northTakeThisOuTspamCIRRUSRESEARCH.CO.UK]
> Sent: Thursday, February 06, 2003 9:36 AM
> To:   .....PICLISTKILLspamspam@spam@MITVMA.MIT.EDU
> Subject:      [PIC]: Using Timer 2 as clock for SPI?
>
> Hi everyone,
>
> How exactly do I use Timer 2 as the clock source for SPI? I am using a
> 17C756A, but guess it will be similar on other micros. Does the clock
> toggle
> every time the timer 'ticks', or only when the timer rolls over and
> generates an interupt? The data book does not describe it well.
>
> I am trying to get an ~2.5MHz clock speed for my SPI link with a 20MHz
> xtal,
> can it be done?
>
I'm not fammiliar with the 17C series, but in the 16x the SPI clock can be
derived from Fosc/4, Fosc/16, Fosc/64 or Timer 2 output/2.  The timer
outputs a clock when TMR2 matches the value in PR2, when the TMR2 register
is reset.  Thus a lower value in PR2 will give a faster clock rate. The
datasheet should give full details on the operation of the Timer2.

Regards

Mike

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\02\06@090853 by Olin Lathrop

face picon face
> How exactly do I use Timer 2 as the clock source for SPI? I am using a
> 17C756A, but guess it will be similar on other micros.

I wouldn't be guessing here.  You should read the data sheet for each
family as you use it.  The 17 family is a little older than the 16 and has
some differences in the UART and maybe the MSSP too.

> Does the clock toggle
> every time the timer 'ticks', or only when the timer rolls over and
> generates an interupt? The data book does not describe it well.
>
> I am trying to get an ~2.5MHz clock speed for my SPI link with a 20MHz
xtal,
> can it be done?

I've only used the PIC17 MSSP in IIC mode, so I can only tell you my
interpretation of the manual.  It seems rather clear, however.  You set
the SSPM3..SSPM0 bits in SSPCON1 to 0011 to select SPI master mode with
clock = timer2 / 2.  You want 2.5MHz, which is Fosc/8 in your case.  Set
up timer 2 to increment from Fosc/4, then set the period register PR2 to 0
so that the timer 2 output is also Fosc/4.  The SPI clock will then be
Fosc/8.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\02\06@094811 by Graham North

flavicon
face
<snip>
set the period register PR2 to 0
so that the timer 2 output is also Fosc/4.  The SPI clock will then be
Fosc/8.
<snip>

Olin, if I set PR2 to 0, then the timer will not increment I believe. Am I
correct?

Thanks

Graham

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\02\06@095019 by Olin Lathrop

face picon face
> Olin, if I set PR2 to 0, then the timer will not increment I believe. Am
I
> correct?

I think so, but that's exactly what you want.  The output of timer 2 will
then be Fosc/4.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\02\06@114608 by Graham North

flavicon
face
If I set PR2 to 0, I get no SPI clock at all. Is this correct?

Graham


> Olin, if I set PR2 to 0, then the timer will not increment I believe. Am
I
> correct?

I think so, but that's exactly what you want.  The output of timer 2 will
then be Fosc/4.

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\02\06@133303 by Olin Lathrop

face picon face
> If I set PR2 to 0, I get no SPI clock at all. Is this correct?

It's not what I expected it would do.  I thought the output of timer 2 was
Fosc / (PR2+1), which in this case would be Fosc.  But if you've tested it
and found it to work the other way, then that must be how it works.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

More... (looser matching)
- Last day of these posts
- In 2003 , 2004 only
- Today
- New search...