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

Ads

Discussion Groups

Discussion Groups | Piclist | Differences in CCP between 16F819 and 18F452

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.

Differences in CCP between 16F819 and 18F452 - Alan Marconett - Jan 19 13:48:00 2006

Hi to the list,

I've got a project to generate stepper pulses on a PIC. It is currently
running on an 18F452, and I need to get it running on a 16F819 as well.

I'm using TMR1 and CCP1 to generate a 25Khz interrupt (40uS period) 10Mhz
XTAL, PLL on for '452.

I'm assuming that it's something in the TMR1/CCP1 setup differences; or the
operation of the CCP at this point.

The data sheets for the two PICs DO read a little differently,

On the '819

(one CCP) it says mode 1011 "Compare mode, trigger special event (CCP1IF bit
is set, CCP1 pin is unaffected); CCP1 resets TMR1 and starts an A/D
conversion (if A/D is enabled)".

On the '452

(two CCPs) mode 1011 "Compare mode, trigger special event (CCPIF bit is
set)".

I AM using an A/D, It's OK if a conversion gets started, although I just
start it every 500uS for myself. I see the CCP1IF bit is set, but does it
also generate the CCP interrupt I need? In the '452 it appears that the 2nd
CCP behaves like a '819 CCP ( with the A/D; OK, I'm using CCP1).

I suspect I'm not getting the CCP1 interrupts. I HAVE reduced the interrupt
Freq. to 150 uS period vs. 40 uS for the '819. The interrupt routine is
shared in the '819, separate and prioritized for the '452,

if(CCP1IF && CCP1IE) /* if CCP1 mask enabled and interrupt */
StepperISR(); if(TMR0IF && TMR0IE) /* handle TMR0 for system ticks */
{
... System ticks derived from TMR0 are working. My "keep alive" LED is
flashing, the A/D is working and displaying on the LCD.

Timer 1 initialization is the same for both:

T1CON = 0b00000001; /* TMR1 on */
TMR1IF = 0; /* TMR1 overflow interrupt flag 10/5/5 */
TMR1IE = 0; /* TMR1 overflow interrupt disabled */ CCP initialization is the same for both:

CCP1CON = 0b00001011; /* Compare generates INT and clears TMR1 */
CCPR1L = (const)(PRELOAD_CCPR1L);
CCPR1H = (const)(PRELOAD_CCPR1H);
CCP1IE = 1; /* enable CCP1 interrupt */

Thanks in advance for any ideas!

Alan KM6VV




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