PIC templates

Dummies question here...

I'm starting out on a new PIC device 18LF14K22, using MPLAB / C18. Where can I find templates with config bits / int vector definitions etc all ready to go?

I poked around on Microchips site with no success.

Thanks

Reply to
Dennis
Loading thread data ...

can

to

Use those for the 18F14K22?

Leon

Reply to
Leon

Use those for the 18F14K22?

Leon

Ummm yeah, no rocket surgeon here...I'm pushing on learning C (C18). I've been using a 18F1330 and have changed to the 18LF14K22. The C18 compiler throws up a bunch of errors due to differences between the two devices. A template would save a lot of to and fro-ing with the data sheet to get things going sorting out niggly little things like OSC on the '1330 translates to FOSC on the 'LF14k22. Trivial I know but I figured templates might exist....

cheers

Reply to
Dennis

????

by template you mean 18LF14K22.h ???

In your mcc18 install directory, ../h/p18lf14K22.h is there.

Take a look I'll wait ......

h
Reply to
hamilton

"hamilton" wrote in message news:ie2q3i$otp$ snipped-for-privacy@news.eternal-september.org...

Nope. More like what I've attached below. Judging by the responses I don't think they exist (or are regarded as too simple). Thanks for the reply.

;DIRECTIVE TO DEFINE PROCESSOR #INCLUDE ;PROCESSOR SPECIFIC VARIABLE DEFINITIONS

;CONFIGURATION BITS ;MICROCHIP HAS CHANGED THE FORMAT FOR DEFINING THE CONFIGURATION BITS, PLEASE ;SEE THE .INC FILE FOR FUTHER DETAILS ON NOTATION. BELOW ARE A FEW EXAMPLES.

; OSCILLATOR SELECTION: CONFIG FOSC = IRC ; INTERNE CONFIG PCLKEN = ON ; Primary clock enabled CONFIG FCMEN = ON ; Fail-Safe Clock Monitor enabled ; IESO = OFF Oscillator Switchover mode disabled ; IESO = ON Oscillator Switchover mode enabled CONFIG PWRTEN = OFF ; PWRT disabled CONFIG BOREN = OFF ; Brown-out Reset disabled in hardware and software ; Brown Out Voltage: ; BORV = 30 VBOR set to 3.0 V nominal ; BORV = 27 VBOR set to 2.7 V nominal ; BORV = 22 VBOR set to 2.2 V nominal ; BORV = 19 VBOR set to 1.9 V nominal CONFIG WDTEN = OFF ; WDT is controlled by SWDTEN bit of the WDTCON register ; Watchdog Timer Postscale Select bits: ; WDTPS = 1 1:1 ; WDTPS = 2 1:2 ; WDTPS = 4 1:4 ; WDTPS = 8 1:8 ; WDTPS = 16 1:16 ; WDTPS = 32 1:32 ; WDTPS = 64 1:64 ; WDTPS = 128 1:128 ; WDTPS = 256 1:256 ; WDTPS = 512 1:512 ; WDTPS = 1024 1:1024 ; WDTPS = 2048 1:2048 ; WDTPS = 4096 1:4096 ; WDTPS = 8192 1:8192 ; WDTPS = 16384 1:16384 ; WDTPS = 32768 1:32768 CONFIG MCLRE = ON ; MCLR pin enabled, RA3 input pin disabled CONFIG HFOFST = OFF ; The system clock is held off until the HFINTOSC is stable. CONFIG STVREN = OFF ; Stack full/underflow will not cause Reset CONFIG LVP = OFF ; Single-Supply ICSP disabled CONFIG BBSIZ = OFF ; 1kW boot block size CONFIG XINST = OFF ; Instruction set extension and Indexed Addressing mode disabled (Legacy mode) CONFIG CP0 = OFF ; Block 0 not code-protected CONFIG CP1 = OFF ; Block 1 not code-protected CONFIG CPB = OFF ; Boot block not code-protected CONFIG CPD = OFF ; Data EEPROM not code-protected CONFIG WRT0 = OFF ; Block 0 not write-protected CONFIG WRT1 = OFF ; Block 1 not write-protected CONFIG WRTB = OFF ; Boot block not write-protected CONFIG WRTC = OFF ; Configuration registers not write-protected CONFIG WRTD = OFF ; Data EEPROM not write-protected CONFIG EBTR0 = OFF ; Block 0 not protected from table reads executed in other blocks CONFIG EBTR1 = OFF ; Block 1 not protected from table reads executed in other blocks CONFIG EBTRB = OFF ; Boot block not protected from table reads executed in other blocks

;****************************************************************************** ;VARIABLE DEFINITIONS

CBLOCK 0X080 WREG_TEMP ;VARIABLE USED FOR CONTEXT SAVING STATUS_TEMP ;VARIABLE USED FOR CONTEXT SAVING BSR_TEMP ;VARIABLE USED FOR CONTEXT SAVING ENDC

CBLOCK 0X000 EXAMPLE ; EXAMPLE OF A VARIABLE IN ACCESS RAM EXEMPLE2 ; UN AUTRE OCTET ENDC

;EEPROM DATA ORG 0XF00000 DE "TEST DATA",0,1,2,3,4,5

; DEFINITION DES CONSTANTES RAMADR EQU 0X80

; VECTEUR DE RESET ORG 0X0000 GOTO START ; GO TO START OF MAIN CODE

;HIGH PRIORITY INTERRUPT VECTOR ORG 0X0008 BRA HIGHINT ; GO TO HIGH PRIORITY INTERRUPT ROUTINE

;LOW PRIORITY INTERRUPT VECTOR AND ROUTINE ORG 0X0018

MOVFF STATUS,STATUS_TEMP ;SAVE STATUS REGISTER MOVFF WREG,WREG_TEMP ;SAVE WORKING REGISTER MOVFF BSR,BSR_TEMP ;SAVE BSR REGISTER ; *** INTERRUPTION DE BAS NIVEAU A ECRIRE MOVFF BSR_TEMP,BSR ;RESTORE BSR REGISTER MOVFF WREG_TEMP,WREG ;RESTORE WORKING REGISTER MOVFF STATUS_TEMP,STATUS ;RESTORE STATUS REGISTER RETFIE

;HIGH PRIORITY INTERRUPT ROUTINE HIGHINT: ; *** INTERRUPTION PRIORITAIRE A ECRIRE RETFIE FAST

;START OF MAIN PROGRAM

Reply to
Dennis

Em 13/12/2010 03:49, Dennis escreveu:

[snipped]
[snipped]

Dennis,

If I understood correctly what you want, and since you mention you want go the C18 route, I think you should check the PIC18F Peripheral Library Help Document (it is in the MCC18\doc folder in your C18 installation).

This library has a set of functions, and for each peripheral a specific one to set parameters and/or initialize the peripheral, so you won't need to think in terms of individual bits. The document explain the use of macros used for the options, so you have some homework to do.

If you peruse the three examples in D:\MCC18\example\users_guide\, you'll find they use the peripheral libraries.

Another option you may try is the utility called VDI which has a GUI for setting the peripheral options and then it generates a module (C or ASM) which you include in your project. This may be useful if for some reason you don't want or can not use the libraries.

HTH

-- Cesar Rabak

--
Cesar Rabak
GNU/Linux User 52247.
 Click to see the full signature
Reply to
Cesar Rabak

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.