• AVR Freaks

Hot!MPLABX 5.35 & 5.40 Unable to change array element value in variable debug window

Author
Brian_Stu
Senior Member
  • Total Posts : 35
  • Reward points : 0
  • Joined: 2017/03/24 08:38:46
  • Location: UK
  • Status: offline
2020/05/26 13:26:41 (permalink)
5 (1)

MPLABX 5.35 & 5.40 Unable to change array element value in variable debug window

I recently added this to an old thread and was advised to create it as a new thread.
 
I'm having  problems with MPLAB X IDE v5.35 (upgraded today to 5.40 - same problem).
Running on Ubuntu 19.10 using pic16F628A (because I have some!).
I am able to change unsigned char variables BUT NOT array variables.
I have an unsigned char array "frm[4]". I added "frm" to the variables window and clicked the drop down to show all 4 elements, but it won't allow me to change any of the element values.
Am I missing something? In my mind the array elements are just like separate variables so surely I should be able to modify them in during debug.
My project is simple, (all in one source file 434 lines of code) and the variables are declared before any code just after the config #pragma statements.
 
The issue is about changing the variables in the debug window not within the code (the program and pic work fine).
I'm just trying to modify the contents of the array during debug to perform timing checks over some part to see if I can speed that part of the code up, but to do so I need to set the array element values to a specific value - I can of course change my code temporarily to preload the array with the values.... but this should work in the debug window!
 
The array is within scope at the debug breakpoint.
 
Trying to change any of the values (bottom right corner of screen shot) doesn't work for any of frm[1] - frm[4] variables.
I can change the T1count variable which was declared in the same code section, all are unsigned char.
 
Yes I did press return after entering the new values - otherwise T1count wouldn't have changed.
 
Hope the screenshot helps to clarify things.
My code works fine, I'm just trying to time things when my digits overflow from 0999 to 1000 and so need to change frm[0-2] to 9's.
 
Noticed this morning that the latest version of MPLAB X IDE is 5.40, I've been using 5.35.
Updated to 5.40 and still have the same problem.
 
 
Update---
I tried this morning to create a cut down version of the code with just the arrays to test on it's own === this worked OK
So I'm now even more confused!!!
The File register addresses for this cut down version were 0x70 upward.
The arrays in my original code are in File register addresses (General Purpose Addresses) 0x20-0x27.
I can change the values in the File registers view (Window/Target Memory Views/File Registers).
The function is located within an interrupt routine (if that makes any difference).
I can provide the full code if required (434 lines).
 
Is this something peculiar related to the General Purpose Addresses (20h-6Fh) and/or the pic16F628A?
 
I've attached a screenshot of the debug window at a breakpoint where I'm updating the array (which works in code), I just can't modify it in the debug window.
 
Any help would be really appreciated
Brian
 
post edited by Brian_Stu - 2020/05/27 00:48:47

Attachment(s)

Attachments are not available: Download requirements not met
#1

8 Replies Related Threads

    Brian_Stu
    Senior Member
    • Total Posts : 35
    • Reward points : 0
    • Joined: 2017/03/24 08:38:46
    • Location: UK
    • Status: offline
    Re: MPLABX 5.35 & 5.40 Unable to change array element value in variable debug window 2020/05/26 13:42:53 (permalink)
    0
    I had problems inserting some parts of the code (getting you don't have permission message when trying to post).
    I've just attached my source code.
    Please excuse my coding, I don't do C, in fact I'm not a software engineer (or wasn't) but get by.
    The program was written a few years ago, and worked, but I came back to the project to add a little extra functionality and wanted to check the timing through the "frame" function where I count frames arriving (from a cine projector) and increment a counter (frm) in BCD for display on a 4 digit LED display.
    This is when I discovered this problem when I tried to change the value in the "frm" array to time a ripple count.
     

    Attachment(s)

    Attachments are not available: Download requirements not met
    #2
    ric
    Super Member
    • Total Posts : 28939
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: MPLABX 5.35 & 5.40 Unable to change array element value in variable debug window 2020/05/26 14:50:09 (permalink)
    0
    Just testing if I can post it.
    //* File:   Telecine2-01.c

    //**********************************************************************
    // Telecine Controller
    // B.Stewart 24/03/2020   rev 2.01 Updated version
    //**********************************************************************

    //**********************************************************************
    //  Usage:                                                             *
    //                         |--\/--|                                    *
    //             DHUN   RA2 -|1   18|- RA1   DTEN                        *
    //             DTHOU  RA3 -|2   17|- RA0   DUNI                        *
    //             SWITCH RA4 -|3   16|- RA7   SEGDP                       *
    //             Vpp    RA5 -|4   15|- RA6   FRAME                       *
    //                    Vss -|5   14|- Vdd                               *
    //             CLKIN  RB0 -|6   13|- RB7   SEGG                        *
    //             SEGA   RB1 -|7   12|- RB6   SEGF                        *
    //             SEGB   RB2 -|8   11|- RB5   SEGE                        *
    //             SEGC   RB3 -|9   10|- RB4   SEGD                        *
    //                         --------                                    *
    //                                                                     *
    //**********************************************************************

    //                                                                     *
    // Notes on operation                                                  *
    // CLKIN is i/p from FRAME sensor (High edge FRAME present) IOCH       *
    //      increments FRAME count and fps count.                          *
    //      also sets FRAME o/p high for approx 20ms.                      *
    // TIMER 1 O/FLOW (1sec) copies fps counts (units & tens to hold counts*
    //      then resets fps counts to count for new second                 *
    // SWITCH i/p (LOW) short press toggles display (FRAME/fps)            *
    //      long press (>1s) resets FRAME counter, all variables and sets  *
    //      display to FRAME count                                         *
    //                                                                     *
    // dig o/p's DUNI,DTEN,DHUN,DTHOU display dig Driver outputs (high)    *
    // SEGA-G o/p's & SEGment display drive outputs (high)                 *
    // FRAME o/p. High for ~20mS on each CLKIN (high edge) reset by TMR2   *
    //      match with PR2.                                                *
    //                                                                     *
    //                                                                     *
    //**********************************************************************
    //
    // 2.01 24/05/2020  Corrected some comments related to Timer 1 with
    //                  correct values for frequency of 125KHz.
    //                    general clean up.
    // 2.0  21/04/2017  Updated version. Increased frame count from 9999
    //                  to 15999 by permitting Hexadecimal values for
    //                  thousands digit. Changed to use of arrays for
    //                  digit counts.
    // 1.0  16/04/2017  Working version. Shortened display update to 4ms
    //                  from 8ms. Introduced masks, and lata dummy register
    //                  and blinking DP every second.
    // 0.1  05/04/2017  Initial release.

    //
    //**********************************************************************


    // PIC16F628A Configuration Bit Settings

    // 'C' source line config statements

    // CONFIG
    #pragma config FOSC = INTOSCIO  // Oscillator Selection bits (INTOSC oscillator: I/O function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN)
    #pragma config WDTE = OFF       // Watchdog Timer Enable bit (WDT disabled)
    #pragma config PWRTE = OFF      // Power-up Timer Enable bit (PWRT disabled)
    #pragma config MCLRE = ON       // RA5/MCLR/VPP Pin Function Select bit (RA5/MCLR/VPP pin function is MCLR)
    #pragma config BOREN = OFF      // Brown-out Detect Enable bit (BOD disabled)
    #pragma config LVP = OFF        // Low-Voltage Programming Enable bit (RB4/PGM pin has digal I/O function, HV on MCLR must be used for programming)
    #pragma config CPD = OFF        // Data EE Memory Code Protection bit (Data memory code protection off)
    #pragma config CP = OFF         // Flash Program Memory Code Protection bit (Code protection off)

    // #pragma config statements should precede project file includes.
    // Use project enums instead of #define for ON and OFF.

    #include <xc.h>

    // Define Pinames.

    #define FRAME RA6
    #define SWITCH RA4
    #define CLKIN RB0
    #define DTHOU RA3
    #define DHUN RA2
    #define DTEN RA1
    #define DUNI RA0
    #define SEGA RB1
    #define SEGB RB2
    #define SEGC RB3
    #define SEGD RB4
    #define SEGE RB5
    #define SEGF RB6
    #define SEGG RB7
    #define SEGDP RA7

    //Define Constants

    #define FRAMEON 0x40    //Bitmask to set FRAME out
    #define FRAMEOFF 0xBF   //Bitmask to clear FRAME out
    #define HALFSEC 0xBDF   //Preload value for Timer 1 for 1/2 sec.
    #define PR2VAL 230      //Set PR2 match value to 230 (30ms, was 155~20ms)
    #define DPON 0x80       //Bitmask to set RA7
    #define DPOFF 0x7F      //Bitmask to clear RA7
    #define CLRDIG 0xF0     //Bitmask to clear digits

    // Define 7 Segment display values

    #define ZERO    0x7E
    #define ONE     0x0C
    #define TWO     0xB6
    #define THREE   0x9E
    #define FOUR    0xCC
    #define FIVE    0xDA
    #define SIX     0xFA
    #define SEVEN   0x0E
    #define EIGHT   0xFE
    #define NINE    0xCE
    #define NULL    0x00
    #define AYY     0xEE
    #define BEE     0xF8
    #define CEE     0x72
    #define DEE     0xBC
    #define EEE     0xF2
    #define EFF     0xE2

    // Declare Variables (all 8 bits)
    unsigned char frm[4];                       // Frame count array
    unsigned char fpsc[2], fpsl[2];             // Frames/sec arrays count and latch
                                                // (latched every sec).
    unsigned char display, dig;                 // display frames/fps and dig No.
    unsigned char timecount;                    // Times switch pressed time.
    unsigned char reset = 0;                    // Set to 1 to initialise.
    unsigned char counter;                      // Used to count button press time.
    unsigned char sf[4];                        // 7 SEGment values for FRAME count
    unsigned char lata;                         // Dummy lata variable
    unsigned char T1count;                      //Counter for timer1.

    //Pre define functions

    void initialise(void);
    void clockin(void);
    void timer0(void);
    void timer1(void);
    void timer2(void);
    void frames(void);
    void fps(void);
    void digit(void);
    int seg(int);
    void interrupt isr();


    void main(void)
    {
        OSCF=1;                 //set Internal Osc to 4Mhz
        
                                //Setup I/O Ports
        lata = 0;
        PORTA = 0;
        TRISA = (0x30);         //set up Port A Inputs (SWITCH & (RA5 unused))

        PORTB = 0;
        TRISB = (0x01);         //set up Port B Outputs just RB0 as input
        INTE = 1;               //enable interrupt on CLKIN (RB0))

        
        //Setup Timer1
        T1CON = (0x35);         //TMR1CS=00 (FOSC/4) T1CKPS=11 (prescale=8) T1OSCEN=0 T1SYNC=1 TMR1ON=1.
                                //AT 1Mhz counts TMR1 at 125KHz. TMR1 o/f at 0.524288 secs (without preload)
        TMR1IE = 1 ;            //Enable Timer1 interrupts
        PEIE = 1;               //Enable Peripheral Interrupt (for Timer1 and CLKIN)
                        
        //Setup Timer0
        OPTION_REG = (0x03);    //Timer 0 FSC/4, PS 16,Weak Pull-ups enabled
        INTEDG = 1;             //Set positive edge interrupt (CLKIN))
        TMR0IE = 1;             //Enable Timer 0 Interrupts

        
        //Setup Timer2;
        PR2 = PR2VAL;           //Set PR2 match value to(~20ms)
        T2CON = 0x3B;           //Timer 2 off, prescale 1:16 Postscale 1:8 (~20mS)
        TMR2IE = 1;             //Enable Timer2 Interupts
        TMR2 = 0;               //Clear Timer2
        
        GIE = 1;                //Enable all active interrputs
        initialise();           //Call initialise Function to set all variables
        
        
        while (1)
        {
            if (reset)
                initialise();
        }
        
    }


    //Main Interrupt Service Routine (isr)
    void interrupt isr()
    {
        //Check which interrupt occurred
        if(TMR0IF)
        {                       //Was it Timer 0?
            timer0();
            TMR0IF = 0;         //Clear Timer0 Flag
        }
            
        if(TMR1IF)
        {                       //Was it Timer1?
            TMR1 = HALFSEC;     //preload timer1 to give ~ 1/2 sec
            timer1();
            TMR1IF = 0;         //Clear Timer1 Flag
        }
        
        if(INTF)
        {                       //Was it an interrupt CLKIN pin (RB0)?
            clockin();
            INTF = 0;           //Clear Flag for pin RA3
        }
        if(TMR2IF)
        {                       //Was it Timer2?
            timer2();
            TMR2IF = 0;         //Clear Timer2 flag
        }
    }




    //General Functions

    void initialise(void)
    {
        char i;                                     // Define variable i locally
        reset = display = 0;
        fpsc[0] = fpsc[1] = fpsl[0] = fpsl[1] = 0;  // Clear fps counts
        for(i=0; i<=3; i++)
        {
            frm[i] = 0;                             // clear frame count digits
            sf[i] = ZERO;                           // 7 seg displays to 0
        }
    }
            
            
     
    void timer0(void)               //Every 8.192ms
    {
        digit();                    //call digit function to step around LCD digits
        if(SWITCH)
        {
            if (timecount > 122)    //Long press > 1sec
                reset = 1;
            else
            {
                if (timecount > 6)  //Short press between 50ms & 1s
                    display ^= 1;   //Toggle display (XOR with 1)
            }
            timecount = 0;          //Clear timecount also if <50ms (contact bounce)
        }
        else
            timecount++;

           
    }


    void timer1(void)               //Timer 1 interrupt, every half second (0.503s)
    {                               //Copy fps values to Hold values and clear counts.
        T1count++;
        if (T1count & 1)
        {                           //Act on alternate T1 interrupts to get 1 second
            lata = lata & DPOFF;    //Set DP off
            PORTA = lata;
            return;
        }                           //Odd count so 1/2 sec
        else
        {                           //Whole second
            lata = lata | DPON;     //Set DP on
            PORTA = lata;
            fpsl[0] = seg(fpsc[0]); //Copy 7 SEGment fps counts to hold counts for display
            fpsl[1] = seg(fpsc[1]);
            fpsc[0] = fpsc[1] = 0;  //And clear counts
        }
    }

    void clockin(void)              //CLKIN pos edge (IOC) new FRAME received.
    {
        lata = lata | FRAMEON;      //Set RA6 high (FRAME pulse)
        PORTA = lata;
        TMR2ON = 1;                 //Start Timer2 to start 20ms pulse (ends with TMR2 int.)
        frames();
        fps();
    }

    void frames(void)               //increment FRAME count BCD variables
    {
        char i;                     //define i locally

        frm[0]++;
        if(frm[0]>9)
        {                           //if more than 9 then clear and increment next digit
            frm[0] = 0;
            frm[1]++;
            if(frm[1]>9)
            {
                frm[1] = 0;
                frm[2]++;
                if(frm[2]>9)
                {
                    frm[2] = 0;
                    frm[3]++;
                    if(frm[3]>15)   //allow hexadecimal on thous (upto 15999)
                        frm[3] = 0;
                }
            }
        }
        for(i=0; i<=3; i++)
        {
            sf[i] = seg(frm[i]);    //Get 7 SEGment values for display
        }
    }

    void fps(void)                  //increment FPS count BCD variables
    {
        fpsc[0]++;
        if(fpsc[0]>9)
        {
            fpsc[0] = 0;
            fpsc[1]++;
            if(fpsc[1]>9) fpsc[1] = 0;
        }
    }

    void digit(void)
    {
        dig++;
        if(dig>3) dig = 0;
        if(display)
        {               // display=1, show fps count 2 (digs only).
            switch(dig)
            {
                case 0:
                    lata = ((lata & CLRDIG) | 1);   // DUNI
                    PORTA = lata;
                    PORTB = fpsl[0];
                    break;
                case 1:
                    lata = ((lata & CLRDIG) | 2);   // DTEN
                    PORTA = lata;
                    PORTB = fpsl[1];
                    break;
                case 2:
                    lata = ((lata & CLRDIG) | 4);   //DHUN
                    PORTA = lata;
                    PORTB = NULL;
                    break;
                case 3:
                    lata = ((lata & CLRDIG) | 8);   //DHUN
                    PORTA = lata;
                    PORTB = NULL;
                    break;
            }
        }
        else
        {                       // display=0, show FRAME count digs.
            switch(dig)
            {
                case 0:
                    lata = ((lata & CLRDIG) | 1);   // DUNI
                    break;
                case 1:
                    lata = ((lata & CLRDIG) | 2);   // DTEN
                    break;
                case 2:
                    lata = ((lata & CLRDIG) | 4);   // DHUN
                    break;
                case 3:
                    lata = ((lata & CLRDIG) | 8);   // DTHOU
                    break;
            }
            PORTA = lata;
            PORTB = sf[dig];
        }
    }


    void timer2(void)               //Timer 2 interrupt. turn off FRAME pulse after ~20mS (RA5)
    {
        lata = lata & FRAMEOFF;     //Set FRAME o/p low (clear bit 6)
        PORTA = lata;
        TMR2ON = 0;                 //Stop Timer 2
        TMR2 = 0;                   //Clear Timer2 (Ready for next pulse.
    }

    int seg(value)                  //Function to get 7 SEGment display values for number
    {
        switch(value)
        {
            case 0:
                return(ZERO);
            case 1:
                return(ONE);
            case 2:
                return(TWO);
            case 3:
                return(THREE);
            case 4:
                return(FOUR);
            case 5:
                return(FIVE);
            case 6:
                return(SIX);
            case 7:
                return(SEVEN);
            case 8:
                return(EIGHT);
            case 9:
                return(NINE);
            case 10:
                return(AYY);
            case 11:
                return(BEE);
            case 12:
                return(CEE);
            case 13:
                return(DEE);
            case 14:
                return(EEE);
            case 15:
                return(EFF);
            default:
                return 0;
        }
    }


    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #3
    ric
    Super Member
    • Total Posts : 28939
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: MPLABX 5.35 & 5.40 Unable to change array element value in variable debug window 2020/05/26 15:03:20 (permalink)
    0
    Your code actually looks pretty good :)
    One comment, the seg() function is declared as
    int seg(int);

    but in fact you only ever give it "unsigned char" parameters, and only want "unsigned char" back, so it should be
    unsigned char seg(unsigned char);

    (i.e. don't use 16 bit variables when 8 bit will do.)
     
    The whole thing would be quicker/more efficient if coded as a simple array lookup.
     
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #4
    ric
    Super Member
    • Total Posts : 28939
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: MPLABX 5.35 & 5.40 Unable to change array element value in variable debug window 2020/05/26 15:13:29 (permalink)
    0
    Brian_Stu
    Running on Ubuntu 19.10 using pic12F628A (because I have some!).

    No such PIC. I guess you mean PIC16F628A
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #5
    ric
    Super Member
    • Total Posts : 28939
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: MPLABX 5.35 & 5.40 Unable to change array element value in variable debug window 2020/05/26 15:27:51 (permalink)
    0
    Example for seg lookup
    const unsigned char lookup[] =
        {ZERO, ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, NULL, AYY, BEE, CEE, DEE, EEE, EFF};

    unsigned char seg(unsigned char value)                  //Function to get 7 SEGment display values for number
    {
        if (value > 15)
            return 0;
        return lookup[value];
    }


    Of course, if you can guarantee "value" will never exceed 15, you can skip the test.
    On some older PICs this will run a little faster if you do NOT put the "const" qualifier on the array definition.
    (So it reads from RAM rather than ROM)

    If you replaced the PC16F628A with a PIC16F18444 you would get the fast ROM lookup, as well as no need to do software shadowing of PORTA.
    post edited by ric - 2020/05/26 16:13:37

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #6
    Brian_Stu
    Senior Member
    • Total Posts : 35
    • Reward points : 0
    • Joined: 2017/03/24 08:38:46
    • Location: UK
    • Status: offline
    Re: MPLABX 5.35 & 5.40 Unable to change array element value in variable debug window 2020/05/27 00:37:47 (permalink)
    0
    ric, Many thanks for posting my code and your comments, they are very useful.
    unsigned char seg(unsigned char);

    Yes, absolutely only using 8 bits, should have spotted this rookie.
     
    const unsigned char lookup[] =
        {ZERO, ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, NULL, AYY, BEE, CEE, DEE, EEE, EFF};

    unsigned char seg(unsigned char value) //Function to get 7 SEGment display values for number
    {
        if (value > 15)
            return 0;
        return lookup[value];
    }

    Will give that a try but will need to remove the 11th value "NULL" from the array.
    That was a hang over from the 1st version before I added hex letters, being constants the order didn't matter.
    "NULL" is used elsewhere to give a blank digit.
     
    ricNo such PIC. I guess you mean PIC16F628A

    Yes!. I've also been working with a 12F683 for motor speed control of my cine projector, hence the 12.
    I've now corrected this in the original post.
     
    Still don't know why I can't change the array values in the variable debug window!
    cheers.
     
     
     
    post edited by Brian_Stu - 2020/05/27 00:51:12
    #7
    Brian_Stu
    Senior Member
    • Total Posts : 35
    • Reward points : 0
    • Joined: 2017/03/24 08:38:46
    • Location: UK
    • Status: offline
    Re: MPLABX 5.35 & 5.40 Unable to change array element value in variable debug window 2020/05/27 04:53:30 (permalink)
    0
    ric, tried replacing the case statements with the lookup array which speeded things up a bit.
    stepping over in original version took 26us
            fpsl[0] = seg(fpsc[0]); //Copy 7 SEGment fps counts to hold counts for display

    changing to char for the seg function reduced this to 22us.
    changing the seg function to use your suggested lookup array actually increased this to 23us but defining the array as (without const - to use RAM rather than ROM) reduced this to 15us.
    unsigned char lookup[] =
        {ZERO, ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, AYY, BEE, CEE, DEE, EEE, EFF};

     
    This all left the seg function pretty bare and didn't need the >15 check. So removed the function and replaced all calls to invoke the new array instead so;-
            fpsl[0] = seg(fpsc[0]); //Copy 7 SEGment fps counts to hold counts for display

    becomes:-
            fpsl[0] = lookup[fpsc[0]]; //Copy 7 SEGment fps counts to hold counts for display

    Stepping over this now takes only 8us (big improvement from my original 22us).
    It also uses less program and data memory and reduces stack use, all a bonus.
     
    Still don't understand why I can't modify ANY of the array values in the variable debug window.
    In fact it appears that I can't modify any of the variables (whatever type) which are located in the General Purpose Register space - in my case addresses 0x20-0x3D, I can only modify variables which reside in address space 0x70-0x7F.
    Maybe I should change the title to:-
    MPLABX 5.35 & 5.40 Unable to change variables in GPR space in the variable debug window?
    Does this apply to other PIC's or just this ancient 16F628A?
     
     
     
     
     
    #8
    ric
    Super Member
    • Total Posts : 28939
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: MPLABX 5.35 & 5.40 Unable to change array element value in variable debug window 2020/05/27 05:02:53 (permalink)
    0
    Brian_Stu
    changing the seg function to use your suggested lookup array actually increased this to 23us but defining the array as (without const - to use RAM rather than ROM) reduced this to 15us.

    As I mentioned, ROM lookup is fairly inefficient on those old PIC16Fxxx devices.
    Any newer one, PIC16F1xxx or PIC16F1xxxx, can do the ROM lookup in virtually the same time as a RAM lookup.
    (I think it's one instruction cycle slower).
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #9
    Jump to:
    © 2020 APG vNext Commercial Version 4.5