CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

lcd_symbol() on PIC16F19175 [Solved]

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
snock



Joined: 10 Oct 2011
Posts: 24

View user's profile Send private message

lcd_symbol() on PIC16F19175 [Solved]
PostPosted: Sun Jun 02, 2019 11:10 am     Reply with quote

Hello. I just upgraded to the latest v5 compiler (v5.085) and the lcd_symbol() is hanging. I've used CCS successfully with the LCD peripheral on a PIC16F1937 in the past without problems, but on the 16F19175 it's a no-go.

I don't think that I am doing anything wrong, but it's always possible. It's not the hardware either. I can make the LCD work with XC8.

Any pointers or is this a compiler bug?

Code:

// * LCD CONFIGURATION ********************************************************
// *  BIT:       7       6       5       4       3       2       1       0    *
// *  SEGMENT:   A       B       C       D       E       F       G       DP   *
#define DIGIT1 COM0+6, COM0+1, COM0+2, COM0+3, COM0+16,COM0+11,COM0+9,COM0+10
#define DIGIT2 COM0+19,COM0+17,COM0+8, COM0+18,COM0+20,COM0+0, COM0+13,COM0+14
#define DIGIT3 COM0+4, COM0+7, COM0+12,COM0+15,COM0+5, COM0+21,COM0+22
// * NUMBERS:               0    1    2    3    4    5    6    7    8    9
const byte NUM_MAP[10] = {0xfc,0x60,0xda,0xf2,0x66,0xb6,0xbe,0xe0,0xfe,0xe6};
// * CHARACTERS:            c    A    L    S    b    t    u    X    -
const byte CHAR_MAP[9] = {0x1a,0xee,0x1c,0xb6,0x3e,0x1e,0x38,0x67,0x02};
#define BLANK 0
// ****************************************************************************

// * PROGRAM DEFINES **********************************************************
#define MAX_MENU     2 // Number of menu items
// ****************************************************************************

// * SUBROUTINE DECLARATIONS **************************************************
void lcd_putc(char c);
void print_num(float num);
float get_num(float val, float min, float max, float min_step);

// * MAIN ROUTINE *************************************************************
void main(void) {
   
   //setup_oscillator(OSC_INTRC | OSC_8MHZ);
   setup_adc(ADC_CLOCK_INTERNAL); // Set up the A/D
   setup_adc_ports(sAN2); // 9V battery condition channel
   set_adc_channel(2);
   port_e_pullups(0x07); // RE0-RE2 need pullups
   setup_timer_1(T1_INTERNAL | T1_DIV_BY_4); // Configure timer 1

   //setup_lcd(LCD_STATIC | LCD_TYPE_B | LCD_B_LOW_POWER, 4, 0x7FFFFF); // Set up LCD hardware
   setup_lcd(LCD_STATIC, 4, 0xfdcefff, 0);
   setup_ccp2(CCP_OFF);

   output_high(RED_LED);
   output_low(YEL_LED);
   output_low(GRN_LED);

   // LCD test
   //lcd_putc("---"); 

   // Set contrast
   lcd_contrast(1);
   delay_ms(2000); // Start up delay

   output_high(GRN_LED);
 
   lcd_symbol(CHAR_MAP[1], DIGIT1);

   // Main program loop
   while(TRUE) {
      output_high(RED_LED);
      delay_ms(1000);
      output_low(RED_LED);
      delay_ms(1000);
   }
}
Ttelmah



Joined: 11 Mar 2010
Posts: 19245

View user's profile Send private message

PostPosted: Sun Jun 02, 2019 11:19 am     Reply with quote

Post the setup code:
Fuses.
Clock statement.
The processor include.

These are always a vital part of the code. Without these we cannot tell
what might be wrong.

Some of the 'defaults' assumed if you don't actually set fuses have changed
in the latest compilers, so this may be causing your issue.
snock



Joined: 10 Oct 2011
Posts: 24

View user's profile Send private message

PostPosted: Sun Jun 02, 2019 11:57 am     Reply with quote

Sorry, yeah, that is important.

Code:

#include<16f19175.h>
#device ADC=10
#fuses RSTOSC_HFINTRC, NOCLKOUT, MCLR, PUT_64MS, PPS1WAY
#use delay(clock=8M)
//#use fast_io(c)

#include<ctype.h>

#zero_ram

// * PORT A DEFINITIONS *******************************************************
#define RX           PIN_A5
// ****************************************************************************

// * PORT B DEFINITIONS *******************************************************
// ****************************************************************************

// * PORT C DEFINITIONS *******************************************************
// ****************************************************************************

// * PORT D DEFINITIONS *******************************************************
#define RED_LED      PIN_D4
#define YEL_LED      PIN_D5
#define GRN_LED      PIN_D6
#define TX           PIN_D7
// ****************************************************************************

// * PORT E DEFINITIONS *******************************************************
#define UP_PB        PIN_E0
#define DN_PB        PIN_E1
#define ENT_PB       PIN_E2
// ****************************************************************************

// * GLOBAL VARIABLES *********************************************************
static int1 dp_flag;
static int8 lcd_pos;
// ****************************************************************************
Ttelmah



Joined: 11 Mar 2010
Posts: 19245

View user's profile Send private message

PostPosted: Sun Jun 02, 2019 12:28 pm     Reply with quote

Change:

#use delay(clock=8M)

To say 'internal=8M'.

The 16f19175 has a much more complex oscillator with programmable
PLL and postscaler ratios. You are not setting these, so it is possible they
are defaulting to the wrong value, and the chip is not running at 8MHz.

This is why a 'first step' should always be the basic 'flash an LED' test
and check what speed the chip is actually doing.

Doubt if this is the problem, but definitely should be checked.
snock



Joined: 10 Oct 2011
Posts: 24

View user's profile Send private message

PostPosted: Sun Jun 02, 2019 7:23 pm     Reply with quote

Okay, I tried that. As far as flashing an LED goes, if you look right past the lcd_symbol() call, I do exactly that. That's how I know that it's hanging on lcd_symbol().
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Jun 02, 2019 11:51 pm     Reply with quote

snock wrote:
I can make the LCD work with XC8.

Post your XC8 test program.
Ttelmah



Joined: 11 Mar 2010
Posts: 19245

View user's profile Send private message

PostPosted: Mon Jun 03, 2019 12:39 am     Reply with quote

The point was that if it was 'hanging', it would not call the flash routine.
You did not say you had run this and tested that the speed was actually
right...

Now 'differences':

1) the 19175 has an optional LCD charge pump. Not sure of the default
fuse setting regarding this, so NOLCDPEN should be used if this is not
being operated.
2) You have not got NOWDT selected. On some chips this defaults to enabled.
The code won't complete waking the LCD if this is the case.
3) Add NOBOOTBLOCK. If the bootblock was enabled it could stop
the code from working.
3) Add NOLVP. LVP enabled is the default on some chips. This could
prevent the code from working.

#fuses RSTOSC_HFINTRC, NOCLKOUT, MCLR, PUT_64MS, PPS1WAY
#fuses NOWDT, NOBOOTBLOCK, NOLCDPEN, NOLVP

Just tested, and I suspect LCDPEN could be the problem. This is enabled
by default, and changes the behaviour of the LCD clock settings...

The clock setup you are using (4), has the comment:
Quote:

Only valid when LCDPEN = 0. If selected when LCDPEN = 1, module will behave as if all sources are disabled


I'd suspect this is your problem.
snock



Joined: 10 Oct 2011
Posts: 24

View user's profile Send private message

PostPosted: Mon Jun 03, 2019 6:29 pm     Reply with quote

Thanks. I tried the fuses you had recommended and it still hangs at lcd_symbol().

I haven't delved into the datasheet for the specific register that the compiler is waiting on, but I noticed this in the .lst file:

Code:

....................    lcd_symbol(CHAR_MAP[1], DIGIT1);
011E:  MOVLB  3A
011F:  BTFSS  0D.4
0120:  GOTO   11F
0121:  MOVLW  EE
0122:  MOVWF  77
0123:  BTFSS  77.7
0124:  BCF    18.6
0125:  BTFSC  77.7
0126:  BSF    18.6
0127:  BTFSS  77.6
0128:  BCF    18.1
0129:  BTFSC  77.6
012A:  BSF    18.1
012B:  BTFSS  77.5
012C:  BCF    18.2
012D:  BTFSC  77.5
012E:  BSF    18.2
012F:  BTFSS  77.4
0130:  BCF    18.3
0131:  BTFSC  77.4
0132:  BSF    18.3
0133:  BTFSS  77.3
0134:  BCF    1A.0
0135:  BTFSC  77.3
0136:  BSF    1A.0
0137:  BTFSS  77.2
0138:  BCF    19.3
0139:  BTFSC  77.2
013A:  BSF    19.3
013B:  BTFSS  77.1
013C:  BCF    19.1
013D:  BTFSC  77.1
013E:  BSF    19.1
013F:  BTFSS  77.0
0140:  BCF    19.2
0141:  BTFSC  77.0
0142:  BSF    19.2


011F: BTFSS 0D.4
0120: GOTO 11F


That stands out to me.
snock



Joined: 10 Oct 2011
Posts: 24

View user's profile Send private message

PostPosted: Mon Jun 03, 2019 6:35 pm     Reply with quote

PCM programmer wrote:
snock wrote:
I can make the LCD work with XC8.

Post your XC8 test program.


Code:

/*
 * File:   main.c
 * Author: x
 *
 * Created on March 9, 2019, 11:37 AM
 */

#define _XTAL_FREQ   1000000


// PIC16LF19175 Configuration Bit Settings

// 'C' source line config statements

// CONFIG1
#pragma config FEXTOSC = OFF    // External Oscillator mode selection bits (Oscillator not enabled)
#pragma config RSTOSC = HFINT1  // Power-up default value for COSC bits (HFINTOSC (1MHz))
#pragma config CLKOUTEN = OFF   // Clock Out Enable bit (CLKOUT function is disabled; i/o or oscillator function on OSC2)
#pragma config VBATEN = OFF     // VBAT Pin Enable bit (VBAT functionality is disabled)
#pragma config LCDPEN = OFF      // LCD Charge Pump Mode bit (LCD Charge Pump is enabled)
#pragma config CSWEN = ON       // Clock Switch Enable bit (Writing to NOSC and NDIV is allowed)
#pragma config FCMEN = ON       // Fail-Safe Clock Monitor Enable bit (FSCM timer enabled)

// CONFIG2
#pragma config MCLRE = ON       // Master Clear Enable bit (MCLR pin is Master Clear function)
#pragma config PWRTE = OFF      // Power-up Timer selection bits (PWRT disable)
#pragma config LPBOREN = OFF    // Low-Power BOR enable bit (ULPBOR disabled)
#pragma config BOREN = ON       // Brown-out reset enable bits (Brown-out Reset Enabled, SBOREN bit is ignored)
#pragma config BORV = LO        // Brown-out Reset Voltage Selection (Brown-out Reset Voltage (VBOR) set to 1.9V on LF, and 2.45V on F Devices)
#pragma config ZCD = OFF        // Zero-cross detect disable (Zero-cross detect circuit is disabled at POR.)
#pragma config PPS1WAY = ON     // Peripheral Pin Select one-way control (The PPSLOCK bit can be cleared and set only once in software)
#pragma config STVREN = ON      // Stack Overflow/Underflow Reset Enable bit (Stack Overflow or Underflow will cause a reset)

// CONFIG3
#pragma config WDTCPS = WDTCPS_31// WDT Period Select bits (Divider ratio 1:65536; software control of WDTPS
#pragma config WDTE = OFF        // WDT operating mode (WDT enabled regardless of sleep; SWDTEN ignored)
#pragma config WDTCWS = WDTCWS_7// WDT Window Select bits (window always open (100%); software control; keyed access not required)
#pragma config WDTCCS = SC      // WDT input clock selector (Software Control)

// CONFIG4
#pragma config BBSIZE = 512     // Boot Block Size Selection bits (Boot Block Size (Words) 512)
#pragma config BBEN = OFF       // Boot Block Enable bit (Boot Block disabled)
#pragma config SAFEN = OFF      // SAF Enable bit (SAF disabled)
#pragma config WRTAPP = OFF     // Application Block Write Protection bit (Application Block NOT write-protected)
#pragma config WRTB = OFF       // Boot Block Write Protection bit (Boot Block NOT write-protected)
#pragma config WRTC = OFF       // Configuration Register Write Protection bit (Configuration Words NOT write-protected)
#pragma config WRTD = OFF       // Data EEPROM Write Protection bit (Data EEPROM NOT write-protected)
#pragma config WRTSAF = OFF     // Storage Area Flash Write Protection bit (SAF NOT write-protected)
#pragma config LVP = ON         // Low Voltage Programming Enable bit (Low Voltage programming enabled. MCLR/Vpp pin function is MCLR.)

// CONFIG5
#pragma config CP = OFF         // UserNVM Program memory code protection bit (UserNVM code protection disabled)

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

#include <xc.h>
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <ctype.h>
#include "lcd.c"
#include "bbupd.c"

void main(void) {

       
    uint8_t volts_tens=1, volts_ones=2, volts_tenths=6;
    uint8_t disp=0;
    uint16_t long_press, disp_tmr;
     
    lcd_init();
         
    LCDDATA0 = 0;
    LCDDATA1 = 0;
    LCDDATA2 = 0;
    LCDDATA3 = 0;
   
    YEL_LED = 1;
    GRN_LED = 1;
   
    board_init();
   
    lcd_printf("-  ");
    __delay_ms(500);
    lcd_printf(" - ");
    __delay_ms(500);
    lcd_printf("  -");
    __delay_ms(500);
    lcd_printf("   ");
   
    while(TRUE) {
        switch(disp) {
            case 0: // Display battery voltage
                lcd_pos=0;
                if(volts_tens>0) lcd_putc(volts_tens+0x30);
                lcd_pos=1;
                lcd_putc(volts_ones+0x30);
                lcd_pos=2;
                lcd_putc(volts_tenths);
                lcd_putc('.');
                break;
            case 1: // Display AC or DC power
                lcd_printf(" ac");
                break;
            case 2: // Display charger status (AC power only)
                lcd_printf("flt");
                break;
            case 3: // Display high level fault
                lcd_printf(" h1");               
                break;
            case 4: // Display inverter failure fault (DC power only)
                lcd_printf("1nf");
                break;
        }
        disp_tmr++;
        if(disp_tmr>500) { // Switch display
            disp_tmr=0;
            disp++;
            if(disp>4) disp=0;
        }
        if(!ENT_BTN) long_press++;
            else long_press=0;
        if(long_press > 900) menu();
        __delay_ms(1);
    }
}



---

Code:

// PIC16LF19175 Configuration Bit Settings

// 'C' source line config statements

// CONFIG1
#pragma config FEXTOSC = OFF    // External Oscillator mode selection bits (Oscillator not enabled)
#pragma config RSTOSC = EXT1X   // Power-up default value for COSC bits (EXTOSC operating per FEXTOSC bits)
#pragma config CLKOUTEN = OFF   // Clock Out Enable bit (CLKOUT function is disabled; i/o or oscillator function on OSC2)
#pragma config VBATEN = OFF     // VBAT Pin Enable bit (VBAT functionality is disabled)
#pragma config LCDPEN = ON      // LCD Charge Pump Mode bit (LCD Charge Pump is enabled)
#pragma config CSWEN = OFF      // Clock Switch Enable bit (The NOSC and NDIV bits cannot be changed by user software)
#pragma config FCMEN = OFF      // Fail-Safe Clock Monitor Enable bit (FSCM timer disabled)

// CONFIG2
#pragma config MCLRE = ON       // Master Clear Enable bit (MCLR pin is Master Clear function)
#pragma config PWRTE = OFF      // Power-up Timer selection bits (PWRT disable)
#pragma config LPBOREN = OFF    // Low-Power BOR enable bit (ULPBOR disabled)
#pragma config BOREN = ON       // Brown-out reset enable bits (Brown-out Reset Enabled, SBOREN bit is ignored)
#pragma config BORV = LO        // Brown-out Reset Voltage Selection (Brown-out Reset Voltage (VBOR) set to 1.9V on LF, and 2.45V on F Devices)
#pragma config ZCD = OFF        // Zero-cross detect disable (Zero-cross detect circuit is disabled at POR.)
#pragma config PPS1WAY = ON     // Peripheral Pin Select one-way control (The PPSLOCK bit can be cleared and set only once in software)
#pragma config STVREN = ON      // Stack Overflow/Underflow Reset Enable bit (Stack Overflow or Underflow will cause a reset)

// CONFIG3
#pragma config WDTCPS = WDTCPS_31// WDT Period Select bits (Divider ratio 1:65536; software control of WDTPS)
#pragma config WDTE = ON        // WDT operating mode (WDT enabled regardless of sleep; SWDTEN ignored)
#pragma config WDTCWS = WDTCWS_7// WDT Window Select bits (window always open (100%); software control; keyed access not required)
#pragma config WDTCCS = SC      // WDT input clock selector (Software Control)

// CONFIG4
#pragma config BBSIZE = 512     // Boot Block Size Selection bits (Boot Block Size (Words) 512)
#pragma config BBEN = OFF       // Boot Block Enable bit (Boot Block disabled)
#pragma config SAFEN = OFF      // SAF Enable bit (SAF disabled)
#pragma config WRTAPP = OFF     // Application Block Write Protection bit (Application Block NOT write-protected)
#pragma config WRTB = OFF       // Boot Block Write Protection bit (Boot Block NOT write-protected)
#pragma config WRTC = OFF       // Configuration Register Write Protection bit (Configuration Words NOT write-protected)
#pragma config WRTD = OFF       // Data EEPROM Write Protection bit (Data EEPROM NOT write-protected)
#pragma config WRTSAF = OFF     // Storage Area Flash Write Protection bit (SAF NOT write-protected)
#pragma config LVP = ON         // Low Voltage Programming Enable bit (Low Voltage programming enabled. MCLR/Vpp pin function is MCLR.)

// CONFIG5
#pragma config CP = OFF         // UserNVM Program memory code protection bit (UserNVM code protection disabled)

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



---

Code:

/*
 * File:   lcd.c
 * Author: x
 *
 * Created on March 10, 2019, 4:42 PM
 */

#include <xc.h>
#include <string.h>

#define bit_test(b,n)   (bool)(b & (1<<n))      /* Test if bit number n in byte b is set   */

// * LCD CONFIGURATION *********************************************************
// * NUMBERS:               0    1    2    3    4    5    6    7    8    9
const char NUM_MAP[10] = {0xfc,0x60,0xda,0xf2,0x66,0xb6,0xbe,0xe0,0xfe,0xe6};
// * CHARACTERS:             c    A    L    S    b    t    u    X    -
//                           H    F    g    E    Z    r    y    P    d
//                           i    n
const char CHAR_MAP[20] = {0x1a,0xee,0x1c,0xb6,0x3e,0x1e,0x38,0x67,0x02, \
                           0x6e,0x8e,0xf6,0x9e,0xda,0x0a,0x66,0xce,0x7a, \
                           0x20,0x2a};
#define BLANK 0
char segment;
uint8_t lcd_pos;
bool dp_flag;
// *****************************************************************************

void lcd_symbol(char c, uint8_t digit);
void lcd_putc(char c);
void lcd_printf(char string[6]);

void lcd_printf(char string[6]) {
    uint8_t digit, i;
    lcd_pos=0;
    for(i=0; i<strlen(string); i++) {
        lcd_putc(string[i]);
        if(string[i+1] != '.') lcd_pos++;
    }
}

void lcd_putc(char c) {
   if(c>=0x30 && c<0x3a) {
      segment=NUM_MAP[c-0x30];
   } else if(c>=0 && c<10) {
       segment=NUM_MAP[c];
   } else {
      switch(tolower(c)) {
         case 'c': segment=CHAR_MAP[0];
                   break;
         case 'a': segment=CHAR_MAP[1];
                   break;
         case 'l': segment=CHAR_MAP[2];
                   break;
         case 's': segment=CHAR_MAP[3];
                   break;
         case 'b': segment=CHAR_MAP[4];
                   break;
         case 't': segment=CHAR_MAP[5];
                   break;
         case 'u': segment=CHAR_MAP[6];
                   break;
         case 'x': segment=CHAR_MAP[7];
                   break;                   
         case '-': segment=CHAR_MAP[8];
                   break;
         case 'h': segment=CHAR_MAP[9];
                   break;
         case 'f': segment=CHAR_MAP[10];
                   break;
         case 'g': segment=CHAR_MAP[11];
                   break;
         case 'e': segment=CHAR_MAP[12];
                   break;
         case 'z': segment=CHAR_MAP[13];
                   break;
         case 'r': segment=CHAR_MAP[14];
                   break;                   
         case 'y': segment=CHAR_MAP[15];
                   break;
         case 'p': segment=CHAR_MAP[16];
                   break;                   
         case 'd': segment=CHAR_MAP[17];
                   break;     
         case 'i': segment=CHAR_MAP[18];
                   break;
         case 'n': segment=CHAR_MAP[19];
                   break;                         
        case ' ': segment=BLANK;
                   break;
         case '.': dp_flag=1;                   
                   break;
         default: segment=BLANK;
      }
   }
   if(dp_flag) {
      segment|=0x01;
      dp_flag=0;
   }
   switch(lcd_pos) {
      case 0: lcd_symbol(segment, 0);
              break;
      case 1: lcd_symbol(segment, 1);
              break;
      case 2: lcd_symbol(segment, 2);
              break;
      default: lcd_pos=0;
   }
}

void lcd_symbol(char c, uint8_t digit) {
    uint8_t i;
    for(i=0; i<8; i++) {
        switch(i) {
            case 0:
                if(digit == 0) LCDDATA2bits.S18C0 = bit_test(c, i); // DP1               
                if(digit == 1) LCDDATA1bits.S11C0 = bit_test(c, i); // DP2
                break;
            case 1:               
                if(digit == 0) LCDDATA3bits.S27C0 = bit_test(c, i); // G1
                if(digit == 1) LCDDATA1bits.S15C0 = bit_test(c, i); // G2
                if(digit == 2) LCDDATA1bits.S10C0 = bit_test(c, i); // G3
                break;
            case 2:
                if(digit == 0) LCDDATA3bits.S26C0 = bit_test(c, i); // F1
                if(digit == 1) LCDDATA0bits.S00C0 = bit_test(c, i); // F2
                if(digit == 2) LCDDATA1bits.S13C0 = bit_test(c, i); // F3
                break;
            case 3:
                if(digit == 0) LCDDATA0bits.S06C0 = bit_test(c, i); // E1
                if(digit == 1) LCDDATA3bits.S25C0 = bit_test(c, i); // E2
                if(digit == 2) LCDDATA2bits.S20C0 = bit_test(c, i); // E3
                break;
            case 4:
                if(digit == 0) LCDDATA2bits.S19C0 = bit_test(c, i); // D1
                if(digit == 1) LCDDATA2bits.S23C0 = bit_test(c, i); // D2
                if(digit == 2) LCDDATA0bits.S03C0 = bit_test(c, i); // D3
                break;
            case 5:
                if(digit == 0) LCDDATA1bits.S14C0 = bit_test(c, i); // C1
                if(digit == 1) LCDDATA1bits.S09C0 = bit_test(c, i); // C2
                if(digit == 2) LCDDATA0bits.S02C0 = bit_test(c, i); // C3
                break;
            case 6:
                if(digit == 0) LCDDATA1bits.S08C0 = bit_test(c, i); // B1
                if(digit == 1) LCDDATA2bits.S22C0 = bit_test(c, i); // B2
                if(digit == 2) LCDDATA0bits.S01C0 = bit_test(c, i); // B3
                break;
            case 7:
                if(digit == 0) LCDDATA0bits.S04C0 = bit_test(c, i); // A1
                if(digit == 1) LCDDATA3bits.S24C0 = bit_test(c, i); // A2
                if(digit == 2) LCDDATA0bits.S07C0 = bit_test(c, i); // A3
        }
    }
}

void lcd_init(void) {       
    FVRCONbits.FVREN = 1;
    PMD5bits.LCDMD = 0;
    LCDCONbits.LCDEN = 0;  // Disable module before configuring
    LCDCONbits.LMUX = 1; // Static COM0
    LCDPS = 3;          // LP 1:4; WFT Type-A waveform;
    LCDREF = 0;         // LCDCST Max contrast (Min Resistance);
    LCDRL = 0xf0;           
    LCDVCON1 = 0;       
    LCDVCON2 = 2; // VDD
    // Segment selection   
    LCDSE0 = 0xff;
    LCDSE1 = 0b11101111;
    LCDSE2 = 0b11011100;
    LCDSE3 = 0x0f;
    LCDSE4 = 0;

    LCDDATA0 = 0;
    LCDDATA1 = 0;
    LCDDATA2 = 0;
   
    LCDCONbits.LCDEN = 1; // Enable
}
[/code]
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jun 03, 2019 6:46 pm     Reply with quote

snock wrote:

011F: BTFSS 0D.4
0120: GOTO 11F


That stands out to me.

Put the .LST file in Symbolic mode. Then you
see this:
Code:
00CF:  BTFSS  LCDPS.WA
00D0:  GOTO   0CF

I noticed this a couple days ago but couldn't find out why it
wasn't seeing the WA bit go high. Other PICs check the same
bit (16F1937), and they work. So I didn't post anything.
I note your lcd_symbol() routine does not call it.
snock



Joined: 10 Oct 2011
Posts: 24

View user's profile Send private message

PostPosted: Mon Jun 03, 2019 8:10 pm     Reply with quote

Okay, so after researching a bit more I have determined that compiler is fine. I added LCD_VOLTAGE_INT_LADDER_VDD to the setup_lcd() after reviewing my original xc8 code and all is well with the WA bit of LCDPS. I guess I felt a bit uneasy starting off because getting the LCD running was pretty trivial on a job I did with the older PIC16F1937 and I have certainly found my share of CCS bugs over the years but otherwise I am a happy customer.

Thanks for all of your help.
Ttelmah



Joined: 11 Mar 2010
Posts: 19245

View user's profile Send private message

PostPosted: Tue Jun 04, 2019 2:37 am     Reply with quote

Well done.
It is one of the 'problems' of the PIC, that there are so many slight variations
in the peripherals. Often ones that do exactly the same job, have little 'extra'
features on the next chip, and (of course), these have to be dealt with...
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group