Pic 18f2321 Setup Template

Thread Starter

Dodgydave

Joined Jun 22, 2012
11,302
Anyone got a template of the this pic-18F2321 to set up for programming, like port settings , A/D set up, Config Reg etc, as there are no app notes on Google or the datasheet, and no help at Microchip either?

I normally use a pic-16F690, mpasm win, (I DONT WANT IT IN C) so i have to convert to this new pic which is giving me a BIG headache!!

i just want a running template so i can get a simple led to run up and down, config setting master-clr off , wdt off etc

anyone gone this working, or am i better binning it and going for a better pic?
 
Last edited:

ErnieM

Joined Apr 24, 2011
8,377
<Extra Sensory Peripheral enabled> .... nope, no good.

Template for what compiler or assembler?

Have you tried a file name search for "18F2321" on your Program Files/Microchip folder?

You couldn't possibly mean "...\Program Files\Microchip\MPASM Suite\Template\Code\18F2321TEMP.ASM" could you?
 

Thread Starter

Dodgydave

Joined Jun 22, 2012
11,302
No i don't have that, mines goes from 18f24j10, any chance of emailing it or a download link where i can update library files? I am using mpasm win compiler. Thanks
 
Last edited:

Thread Starter

Dodgydave

Joined Jun 22, 2012
11,302
Thanks Ernie, got that but still it don't help me, i feel like this is a dead end for this pic,

have decided to bin it and go for the pic16F722


Thanks for all help..
 
Last edited:

atferrari

Joined Jan 6, 2004
4,769
Hola dodgy,

A template is just that; the ONs and OFFs, is you who decide which one goes where. I never used an "official" template. I wrote mine and it works.

Just as a an example, these are the settings for an application implemented with the 18F4431
Rich (BB code):
;000 ON-SCREEN TEXT 08.ASM

  TITLE     "ON-SCREEN TEXT 08"
  
  SUBTITLE  "Started    03.09.09"
  SUBTITLE  "Updated    05.09.09"
  SUBTITLE  "Author Agustiin Tomaas Ferrari  - Buenos Aires"
;------------------------------------------------------------------------------

;Default radix is DECimal!
;XTAL = 4 MHz - HSPLL enabled=> 16 MHz clock.
;On line delay routines for 16 MHz (4*4 MHZ)
;------------------------------------------------------------------------------
 
  Processor 18F4431
  LIST  B=4, C=80, MM=ON, R=DEC, ST=ON, T=OFF

  INCLUDE "P18F4431.INC"
;------------------------------------------------------------------------------

  CONFIG  OSC =HSPLL  ,FCMEN =OFF   ,IESO =OFF    ,PWRTEN =OFF    ,BOREN =OFF
  CONFIG  BORV =27    ,WDTEN =OFF   ,WINEN =OFF   ,WDPS =1        ,T1OSCMX =OFF
  CONFIG  HPOL =HIGH  ,LPOL =LOW    ,PWMPIN =ON   ,MCLRE =ON      ,EXCLKMX =RC3
  CONFIG  PWM4MX =RB5 ,SSPMX =RC7   ,FLTAMX =RC1  ,STVREN =ON     ,LVP =OFF             
  CONFIG  DEBUG =OFF  ,CP0 =OFF     ,CP1 =OFF     ,CP2 =OFF       ,CP3 =OFF             
  CONFIG  CPB =OFF    ,CPD =OFF     ,WRT0 =OFF    ,WRT1 =OFF      ,WRT2 =OFF            
  CONFIG  WRT3 =OFF   ,WRTB =OFF    ,WRTC =ON     ,WRTD =OFF      ,EBTR0 =OFF           
  CONFIG  EBTR1 =OFF  ,EBTR2 =OFF   ,EBTR3 =OFF   ,EBTRB =OFF 
;------------------------------------------------------------------------------

  #INCLUDE "001 EQUS 01.ASM"
  #INCLUDE "004 MACROS 01.ASM"
  #INCLUDE "005 MACROS 02.ASM"
  #INCLUDE "006 MACROS 03.ASM"

;------------------------------------------------------------------------------
Forget any childish idea of binning the micro and going back to the 16F. Install (if not yet installed) the MPLAB IDE and just look for the 18FXXXX.inc file where you have, at the end, all the configuration bits' possible settings. (I have no idea where they are so I look for *.inc files using the Windows' search function).

That way, you have no other option that choosing one amongst the two or more for every item.

One thing: most of the options, when you start by blinking LEDs, should be OFF; unless you are an obfuscating designer, you will want to keep all peripherals off.

When you have more than two options (CLK related is common) you have to think a little more and even read the datsheet, mostly once for all.

Honestly, if I did, you could. Do not give up!

PD: Once writing code, do not forget to disable the input pins, analog by default when you want them being digital.

Once done, you will smile man! :)
 
Last edited:
Top