Pic 18f2321 Setup Template

Discussion in 'Embedded Systems and Microcontrollers' started by Dodgydave, Jul 13, 2013.

  1. Dodgydave

    Thread Starter AAC Fanatic!

    Jun 22, 2012
    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: Jul 13, 2013
  2. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    <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?
  3. Dodgydave

    Thread Starter AAC Fanatic!

    Jun 22, 2012
    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: Jul 13, 2013
  4. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    If you don't have this file you don't have MPASM. They download together.
  5. Dodgydave

    Thread Starter AAC Fanatic!

    Jun 22, 2012
    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: Jul 14, 2013
  6. atferrari

    AAC Fanatic!

    Jan 6, 2004
    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
    Code ( (Unknown Language)):
    2. ;000 ON-SCREEN TEXT 08.ASM
    4.   TITLE     "ON-SCREEN TEXT 08"
    6.   SUBTITLE  "Started    03.09.09"
    7.   SUBTITLE  "Updated    05.09.09"
    8.   SUBTITLE  "Author Agustiin Tomaas Ferrari  - Buenos Aires"
    9. ;------------------------------------------------------------------------------
    11. ;Default radix is DECimal!
    12. ;XTAL = 4 MHz - HSPLL enabled=> 16 MHz clock.
    13. ;On line delay routines for 16 MHz (4*4 MHZ)
    14. ;------------------------------------------------------------------------------
    16.   Processor 18F4431
    17.   LIST  B=4, C=80, MM=ON, R=DEC, ST=ON, T=OFF
    19.   INCLUDE "P18F4431.INC"
    20. ;------------------------------------------------------------------------------
    23.   CONFIG  BORV =27    ,WDTEN =OFF   ,WINEN =OFF   ,WDPS =1        ,T1OSCMX =OFF
    25.   CONFIG  PWM4MX =RB5 ,SSPMX =RC7   ,FLTAMX =RC1  ,STVREN =ON     ,LVP =OFF            
    26.   CONFIG  DEBUG =OFF  ,CP0 =OFF     ,CP1 =OFF     ,CP2 =OFF       ,CP3 =OFF            
    27.   CONFIG  CPB =OFF    ,CPD =OFF     ,WRT0 =OFF    ,WRT1 =OFF      ,WRT2 =OFF            
    28.   CONFIG  WRT3 =OFF   ,WRTB =OFF    ,WRTC =ON     ,WRTD =OFF      ,EBTR0 =OFF          
    30. ;------------------------------------------------------------------------------
    32.   #INCLUDE "001 EQUS 01.ASM"
    33.   #INCLUDE "004 MACROS 01.ASM"
    34.   #INCLUDE "005 MACROS 02.ASM"
    35.   #INCLUDE "006 MACROS 03.ASM"
    37. ;------------------------------------------------------------------------------
    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: Jul 14, 2013
  7. Dodgydave

    Thread Starter AAC Fanatic!

    Jun 22, 2012
    Too late mate its binned and swapped!