1Hz clock using Timer3, 32.768kHz crystal and runs badly on 18F26k22


Closed Thread
Results 1 to 16 of 16

Hybrid View

  1. #1
    Join Date
    Jan 2009
    Location
    Alabama,USA
    Posts
    235


    Did you find this post helpful? Yes | No

    Default Re: 1Hz clock using Timer3, 32.768kHz crystal and runs badly on 18F26k22

    Thank you Chris and Henrik for your comments.

    I am using MCSP, PBP 2.60c, and MPLAB8.83. When I compile from MCSP I get a statement “18F25K22.INC not found”, in addition to other errors. In PBP I have three files for 18F25K22. 18F25K22.INC, 18F25K22.Visual Basic Module, 18F25K22.BAL are in C:\PBP.

    There is NO M18F25K22.INC in C:\PBP\INC.

    If I understand what you are saying, I should copy the P18F25K22.INC from C:\Microchip\MPASM Suite into PBP\INC. Is that correct? If so, should I call it M18F25K22?

    I also find in C:\Mecanique\MPASM has INC files. There is NO P18F25K22 in this folder. Should there also be a P18F25K22 file in this folder?

    Thank you for your help. I’ve been working with this for several days, reloaded all my programs and updating from PBP2.60, 2.60a, 2.60c. My forehead feels like mister-e’s after banging the keyboard for hours!
    Wayne

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default Re: 1Hz clock using Timer3, 32.768kHz crystal and runs badly on 18F26k22

    Hi,
    There should be a 18F25K22.INC, a 18F25K22.BAS and a 18F25K22.BAL file in the PBP folder and there should be a P18F25K22.INC in the MPASMSuite folder. If you need to EDIT the configs (for PBP versions PRIOR to 3.0) the file you should edit is the 18F25K22.INC in the PBP folder. You should not copy and or rename any files.

    My 18F25K22.INC file in C:\PBP looks like this (this is for v2.6):
    Code:
    ;****************************************************************
    ;*  18F25K22.INC                                                *
    ;*                                                              *
    ;*  By        : Leonard Zerman, Jeff Schmoyer                   *
    ;*  Notice    : Copyright (c) 2010 microEngineering Labs, Inc.  *
    ;*              All Rights Reserved                             *
    ;*  Date      : 05/11/10                                        *
    ;*  Version   : 2.60a                                           *
    ;*  Notes     :                                                 *
    ;****************************************************************
    ;Edited 2011-03-02 //Henrik
    ;Commented out configs in order to set in code
            NOLIST
        ifdef PM_USED
            LIST
            "Error: PM does not support this device.  Use MPASM."
            NOLIST
        else
            LIST
            LIST p = 18F25K22, r = dec, w = -311, w = -230, f = inhx32
            INCLUDE "P18F25K22.INC" ; MPASM  Header
    ;        __CONFIG    _CONFIG1H, _FOSC_INTIO67_1H
    ;        __CONFIG    _CONFIG3H, _PBADEN_OFF_3H
    ;        __CONFIG    _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
            NOLIST
        endif
            LIST
    EEPROM_START EQU 0F00000h
    BLOCK_SIZE EQU 64
    As you can see I've commented the default __CONFIG lines here so that I could have them in my program instead. You can do that OR edit the the file to match your needs but DO back it up before changing.

    I don't know why it says it can't find your 18F25K22.INC if it's there. If you happen to have multiple versions of the compiler make sure you're executing the correct one. Also make sure that MCS is indeed pointing to the correct MPASMSuite folder (if you have multiple versions installed), it's usually something like C:\Program Files\Microchip\MPASMSuite\

    /Henrik.

  3. #3
    Join Date
    Jan 2009
    Location
    Alabama,USA
    Posts
    235


    Did you find this post helpful? Yes | No

    Default Re: 1Hz clock using Timer3, 32.768kHz crystal and runs badly on 18F26k22

    Henric, thanks for your comments,
    GO IT! Man what an ordeal. You gave me the key when you said, “it's usually something like C:\Program Files\Microchip\MPASMSuite\”. I had not noticed that I had used “ Find Automatically” for the MPASM file on both computers. MCSP went to Mecanique\MCSP\MPASM. As soon as I used “Find Manually” and located in MPLAB…… All IS Well in the world... I get a small black screen for a few seconds and then "Success xxx bites".

    Thanks a bunch! Thanks a bunch! Thanks a bunch!

    Wayne

  4. #4


    Did you find this post helpful? Yes | No

    Default Re: 1Hz clock using Timer3, 32.768kHz crystal and runs badly on 18F26k22

    Good shout Henrik.

    If it is any consolation Wayne you won't be the first or the last to be stumped in that way.

    Now, if you ever find out why Timer 3 didn't behave the same as Timer 1 for me, feel free to let me know !

    Chris

  5. #5
    Join Date
    Jan 2009
    Location
    Alabama,USA
    Posts
    235


    Did you find this post helpful? Yes | No

    Default Re: 1Hz clock using Timer3, 32.768kHz crystal and runs badly on 18F26k22

    Chris, I'll let you know when I find out! I feel like a dummy for stumbling over that one. I am supprised MCSP would make that blunder when it was looking for MPLAB\MPASM. Oh Well, Automatic is not always Automatic...

  6. #6
    Join Date
    Nov 2008
    Posts
    26


    Did you find this post helpful? Yes | No

    Default Re: 1Hz clock using Timer3, 32.768kHz crystal and runs badly on 18F26k22

    Chris
    A thought accured to me RE timer 3. did you check the configuration bits in CONFIG3H?

    bit 4 T3CMX: Timer3 Clock Input MUX bit
    1 = T3CKI is on RC0
    0 = T3CKI is on RB5


    MOUNTAIN747

    This is an example of config bit for the 18F2x/4xK22 devices based on PBP 2.60C


    asm
    __CONFIG _CONFIG1H, _FOSC_INTIO67_1H & _PLLCFG_OFF_1H & _PRICLKEN_ON_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
    __CONFIG _CONFIG2L, _PWRTEN_ON_2L & _BOREN_OFF_2L & _BORV_285_2L
    __CONFIG _CONFIG2H, _WDTEN_NOSLP_2H & _WDTPS_512_2H
    __CONFIG _CONFIG3H, _CCP2MX_PORTC1_3H & _PBADEN_OFF_3H & _CCP3MX_PORTB5_3H & _HFOFST_OFF_3H & _T3CMX_PORTB5_3H & _P2BMX_PORTC0_3H & _MCLRE_EXTMCLR_3H
    __CONFIG _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _XINST_OFF_4L & _DEBUG_OFF_4L
    __CONFIG _CONFIG5L, _CP0_OFF_5L & _CP1_OFF_5L
    __CONFIG _CONFIG5H, _CPB_OFF_5H & _CPD_OFF_5H
    __CONFIG _CONFIG6L, _WRT0_OFF_6L & _WRT1_OFF_6L
    __CONFIG _CONFIG6H, _WRTC_OFF_6H & _WRTB_OFF_6H & _WRTD_OFF_6H
    __CONFIG _CONFIG7L, _EBTR0_OFF_7L & _EBTR1_OFF_7L
    __CONFIG _CONFIG7H, _EBTRB_OFF_7H

    ENDASM

    You'll probably have to change to suit your application, but the above covers all the configs as a starter.
    any Q's fell free to ask, I'm working on a project using the 44K22 at the moment so know the datasheet quite well.

  7. #7
    Join Date
    Jan 2009
    Location
    Alabama,USA
    Posts
    235


    Did you find this post helpful? Yes | No

    Default Re: 1Hz clock using Timer3, 32.768kHz crystal and runs badly on 18F26k22

    BH_epuk, thanks for the update. I've just stated on the k22's data sheet. I know this is going to be a fun PIC to work with. AND, I may have some questions for you after I digest the next 300 pages!
    Thanks
    Wayne

  8. #8


    Did you find this post helpful? Yes | No

    Default Re: 1Hz clock using Timer3, 32.768kHz crystal and runs badly on 18F26k22

    Quote Originally Posted by BH_epuk View Post
    Chris
    A thought accured to me RE timer 3. did you check the configuration bits in CONFIG3H?

    bit 4 T3CMX: Timer3 Clock Input MUX bit
    1 = T3CKI is on RC0
    0 = T3CKI is on RB5


    MOUNTAIN747
    I'm not sure that could be the cause given the unreliability of the fault. If set up incorrectly it would work consistently poorly. As it is, the 1 second epoch is always on time (suggesting that the correct count of 32768 pulses from the crystal are being used).

    The symptom is that sometimes in the ISR, the interrupt bit for the Timer 3 overflow interrupt doesn't clear when instructed to do so.

    Normal operation is that the timer overflows, an interrut is generated, which is then services and cleared, and one second gets added to the Seconds counter.
    Sometimes, the Seconds counter increments by two instead of one, suggesting that the ISR is called twice and the TMR3 interrupt is serviced twice for only one TMR3 overflow condition.

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts