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 | help pic18 eccp

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.

help pic18 eccp - jr goco - Nov 16 11:58:00 2003

hi!

has anyone been able to work on pic18's eccp pwm mode?
i cannot seem to make the single mode work..





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


Re: help pic18 eccp - Eirik Karlsen - Nov 17 15:52:00 2003

I'm programming on a 18F442, PWM works great....
try extracting the essentials from this code:
 

 LIST P=18F442  ;directive to define processor
 #include <P18F442.INC> ;processor specific variable definitions

;******************************************************************************
;Configuration bits
; The __CONFIG directive defines configuration data within the .ASM file.
; The labels following the directive are defined in the P18F442.INC file.
; The PIC18F442 Data Sheet explains the functions of the configuration bits.
 __CONFIG _CONFIG1H, _OSCS_OFF_1H & _HSPLL_OSC_1H          ;Oscillator switching=OFF. High Speed PLL Oscillator enable=ON.
 __CONFIG _CONFIG2L, _BOR_OFF_2L & _PWRT_ON_2L          ;Brown Out Reset=OFF. Power-up Timer=ON.
 __CONFIG _CONFIG2H, _WDT_OFF_2H              ;Watch Dog Timer=OFF.
 __CONFIG _CONFIG3H, _CCP2MX_OFF_3H             ;Mux on CCP2=OFF.
 __CONFIG _CONFIG4L, _STVR_OFF_4L & _LVP_OFF_4L & _DEBUG_OFF_4L      ;Stack overflow reset=OFF. Low Voltage Programming(ISCP)=OFF. Background Debugger=OFF.
 __CONFIG _CONFIG5L, _CP0_OFF_5L & _CP1_OFF_5L & _CP2_OFF_5L & _CP3_OFF_5L   ;Code Protection=OFF.
 __CONFIG _CONFIG5H, _CPB_OFF_5H & _CPD_OFF_5H          ;Boot Block Code Protection=OFF. Data EEPROM Code Protection=OFF.
 __CONFIG _CONFIG6L, _WRT0_OFF_6L & _WRT1_OFF_6L & _WRT2_OFF_6L & _WRT3_OFF_6L  ;Program blocks 0:3 Write Protection=OFF.
 __CONFIG _CONFIG6H, _WRTC_OFF_6H & _WRTB_OFF_6H & _WRTD_OFF_6H      ;EEPROM Write protection=OFF. Boot Block Write Protection=OFF. Configuration Register Write Protection=OFF.
 __CONFIG _CONFIG7L, _EBTR0_OFF_7L & _EBTR1_OFF_7L & _EBTR2_OFF_7L & _EBTR3_OFF_7L ;Table Read Protection blocks 0:3=OFF.
 __CONFIG _CONFIG7H, _EBTRB_OFF_7H             ;Boot Block Table Read Protection=OFF.
;******************************************************************************
////////////////////////////////////////
;**************** SET UP INTERRUPTS AND PWM1 FOR MOTOR CONTROL *********************************
  MOVLW 0XFF   ;9.7Khz
  MOVWF PR2    ;
  MOVLW 0X25   ;start timer2 with /4 prescaler(for PWM), and /8 postscaler(for PIDcalc interrupt)
  MOVWF T2CON   ;
  MOVFF MOTORPWL,WREG ;get low byte b7:b0
  CLRF TEMP0   ;
  BCF  STATUS,C  ;clear carry
  RRCF WREG   ;
  RRCF TEMP0   ;
  RRCF WREG   ;
  RRCF TEMP0   ;now holds motor PW b1:b0 in b7:b6
  RRNCF TEMP0   ;rotate further to align with CCP1CON
  RRNCF TEMP0   ;now holds motor PW b1:b0 in b5:b4
  COMF TEMP0   ;inverse, PWM pulses must be negative
  MOVFF TEMP0,WREG  ;
  ANDLW 0X30   ;mask out unwanted bits
  CLRF CCP1CON   ;
  IORWF CCP1CON,F  ;write to pwm register L
  MOVFF MOTORPWH,WREG ;get high byte b9:b8
  MOVFF MOTORPWL,TEMP0 ;TEMP0 holds low byte b7:b0
  BCF  STATUS,C  ;
  RRCF WREG   ;
  RRCF TEMP0   ;to get PW low byte shift b9 and b8 into TEMP0, and loose b1:b0
  RRCF WREG   ;
  RRCF TEMP0   ;now holds motor PW b9:b2
  COMF TEMP0   ;inverse, PWM pulses must be negative
  MOVFF TEMP0,WREG  ;
  MOVWF CCPR1L   ;write to pwm register H
  MOVLW 0X0C   ;configure CCP1 for PWM
  IORWF CCP1CON,F  ;
  BSF  RCON,IPEN  ;enable prioritized interrupts
  BSF  PIE1,TMR2IE  ;enable timer2 interrupt
  BCF  IPR1,TMR2IP  ;set low priority for timer2 interrupt
  BSF  INTCON,GIEL  ;global enable low priority int(PIDcalc)
  BSF  INTCON,GIEH  ;global enable low AND high priority interrupts

;********************************************************************************
 

jr goco wrote:

 hi!

has anyone been able to work on pic18's eccp pwm mode?
i cannot seem to make the single mode work..
 

--
*******************************************
VISIT MY HOME PAGE:
<http://home.online.no/~eikarlse/index.htm>
LAST UPDATED: 23/08/2003
*******************************************
Best Regards
Eirik Karlsen
 



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