Sign in

username:

password:



Not a member?

Search piclist



Search tips

Subscribe to piclist



piclist by Keywords

12F675 | 16F628 | 16F84 | 16f877 | 16F877A | 16F88 | 18F458 | ADC | AVR | Bootloader | CAN | CCS | CRC | EAGLE | EEPROM | ICD | ICSP | IDE | JDM | LED | Macros | Microchip | MPLAB | PCB-CAD | PIC10F | Pic12f675 | PIC16F84 | PIC16F84A | PIC16F877 | PIC18 | PIC18F452 | PicBasic | PICC | PICSTART | PWM | RS-485 | RS232 | SMT | SPI | UART | USART | USB | Wireless | Wisp628 | Xilinx

Discussion Groups

Discussion Groups | Piclist | TMR2 output and the SPI block

A discussion group for the PICMicro microcontroller. Also called the Microchip PIC, this list is dedicated to the use and abuse of this fine, simple, microcontroller. Close to topic posts are welcome, ie. general electronics.

TMR2 output and the SPI block - Dennis Clark - Mar 3 13:25:00 2006


   I'm running a 18F6680 at 40MHz which means that the SPI clock's 
slowest setting would be 625KHz, which requires a pretty fast set of 
opto isolators in my  case.  I'd like to run it a bit slower.  TMR2's 
output can be used as the SPI clock, but I'm curious as to the details. 
  Does the PR2 register control this register output?  The document 
isn't that clear - IOW, if I have a 40MHz/4 clock, and PR2 is set to 
255, do I get a 40MHz/4/256 = 25.6KHz clock to the SPI module?  I'd like 
to run this module between 50KHz and 100KHz to keep the cost of the 
optos down.

Has anyone done this and know?

thanks,
DLC
-- 
---------------------------------------
Dennis Clark    TTT Enterprises
---------------------------------------



(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: TMR2 output and the SPI block - Chad Russel - Mar 4 14:13:00 2006

Dennis,

TMR2 has a prescaler or 1/1, 1/4 and 1/16 which can be applied to
Fosc/4 first.  The value of PR2 will be the point at which TMR2 is
reset to start counting up again from zero. I.e., if you set PR2 to 1,
TMR2 will reset every second count, set PR2 to 2 and TMR2 will reset
every third count, therefore TMR2 division == PR2+1.  You can check the
CCP section for a better explanation.  There is also a post scaler on
the match output settable between [1-16]/1.

I think your output should be Fosc/(4 * Prescaler * (PR2 + 1) *
Postscaler)  Therefore your lowest TMR2IF frequecy would be 1525.878906
Hertz with a 40 Mhz clock.  

Check my math.

Chad
	--- Dennis Clark <dlc@dlc@...> wrote:

>    I'm running a 18F6680 at 40MHz which means that the SPI clock's 
> slowest setting would be 625KHz, which requires a pretty fast set of 
> opto isolators in my  case.  I'd like to run it a bit slower.  TMR2's
> 
> output can be used as the SPI clock, but I'm curious as to the
> details. 
>   Does the PR2 register control this register output?  The document 
> isn't that clear - IOW, if I have a 40MHz/4 clock, and PR2 is set to 
> 255, do I get a 40MHz/4/256 = 25.6KHz clock to the SPI module?  I'd
> like 
> to run this module between 50KHz and 100KHz to keep the cost of the 
> optos down.
> 
> Has anyone done this and know?
> 
> thanks,
> DLC
> -- 
> ---------------------------------------
> Dennis Clark    TTT Enterprises
> ---------------------------------------
>
	My software has no bugs, only undocumented features.



(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )