Page 1 of 1

PIC18F25K80 timer1 problem

Posted: Wed Nov 14, 2018 10:25 am
by STibor
Hello!

I compiled an old v6 project in v7.
An old "T1SOSCEN error" emerged.
Old thread: http://www.matrixtsl.com/mmforums/viewt ... 59&t=17312

Re: PIC18F25K80 timer1 problem

Posted: Wed Nov 14, 2018 11:26 am
by Benj
Hello,

For 8-bit PIC devices V7 and V8 use a different compiler to V6 which has a different syntax for accessing registers.

Instead of

Code: Select all

st_bit(t1con, T1OSCEN);
Try this.

Code: Select all

st_bit(T1CON, T1OSCEN);

Re: PIC18F25K80 timer1 problem

Posted: Wed Nov 14, 2018 12:50 pm
by STibor
Thanks,

I know the syntax but there is nothing T1CON, T1SOSCEN bit, only T1CON, SOSCEN.
I think you've passed the bug from an old version of V6.

Re: PIC18F25K80 timer1 problem

Posted: Wed Nov 14, 2018 1:40 pm
by Benj
Hello,

Aha yes in the xc8 compiler definition for the device the T1CON register has these bits.

Code: Select all

typedef union {
    struct {
        unsigned                        :2;
        unsigned NOT_T1SYNC             :1;
    };
    struct {
        unsigned TMR1ON                 :1;
        unsigned RD16                   :1;
        unsigned nT1SYNC                :1;
        unsigned SOSCEN                 :1;
        unsigned T1CKPS                 :2;
        unsigned TMR1CS                 :2;
    };
    struct {
        unsigned                        :4;
        unsigned T1CKPS0                :1;
        unsigned T1CKPS1                :1;
        unsigned TMR1CS0                :1;
        unsigned TMR1CS1                :1;
    };
    struct {
        unsigned                        :3;
        unsigned T1OSCEN                :1;
        unsigned                        :3;
        unsigned T1RD16                 :1;
    };
} T1CONbits_t;

Re: PIC18F25K80 timer1 problem

Posted: Wed Nov 14, 2018 5:35 pm
by STibor
I modified the fcd file.
I replaced T1SOSCEN to SOSCEN.
This is how the timer1 interruption works well.