• AVR Freaks

Hot![SOLVED] Error related to program speed or timing with PIC18FQ47

Page: 12 > Showing page 1 of 2
Author
ishkabum
Starting Member
  • Total Posts : 33
  • Reward points : 0
  • Joined: 2020/09/24 07:42:09
  • Location: 0
  • Status: offline
2020/09/29 11:37:35 (permalink)
0

[SOLVED] Error related to program speed or timing with PIC18FQ47

Hi,
This is using Curiosity HPC. Latch B is connected to data pins for 8-bit driving of an LCD 1602 with 44780 LCD controller. The program is switching some of the on-board LEDs along with button presses of Switch S2. There is a blink routine which I was triggering after holding for a period. I've integrated some code "goLCD.h" which was adapted from an online source. I'm getting an error which I am guessing is something to do with timing. The XTAL_FREQ was set to 4M in the "device_config.h" file.
 
 
I'm including code below:
 
#include <xc.h>
#include "mcc_generated_files/mcc.h"
#include "mcc_generated_files/pin_manager.h"
#include "goLCD.h"

#define LOW 0
#define HIGH 1
#define NOT_PUSHED 0
#define PUSHED 1



//void checkButtonS1(void);
void checkButtonS2(void);
void assignLight(void);
//void blinkLight(void);
void blinkD3Fast(void);
void checkWin(void);
void initLCD(void);

uint8_t btnState = NOT_PUSHED;
uint8_t btn2State = NOT_PUSHED;
uint8_t switchEvent = 0;
uint8_t switch2Event = 0;
int winCount = 0;
uint8_t blinking = 0;

void main(void) {
    SYSTEM_Initialize(); //initialize sys
    ANSELB = 0; //set Port B digital mode
    ANSELD = 0; //set Port D digital mode
    TRISA = 0; //set all outputs
    TRISB = 0; //set all outputs
    TRISD = 0; //set all outputs
  // SWITCH_S1_SetDigitalMode(); //set switch 1 digital
  // SWITCH_S1_SetDigitalInput(); //reading switch 1
    RC5_SetDigitalMode(); //set switch 2 digital mode
    RC5_SetDigitalInput(); //reading switch 2
    
    initLCD();
    
    while(1)
    {
      // checkButtonS1(); //check button S1 for switch event
        checkButtonS2(); //check button S2 for switch event
        assignLight(); //light response if switch event
        
        checkWin(); //check for win-game event
    }
    
    
    return;
}

//void checkButtonS1(void)
//{
// if (btnState == NOT_PUSHED) //we think the button is not pushed
// {
// if (SWITCH_S1_PORT == LOW) //see if the button is pushed
// {
// __delay_ms(100); //de-bouncing
// if (SWITCH_S1_PORT == LOW) //if the button is still pressed
// {
// btnState = PUSHED; //switch on button state
// switchEvent = 1; //raise the flag
// }
// }
// }
//
// else //we think the button is pushed
// {
// if (SWITCH_S1_PORT == HIGH) //if the button is released
// {
// btnState = NOT_PUSHED; //set the button state
// }
//
// }
//}

void checkButtonS2(void)
{
    if (btn2State == NOT_PUSHED) //we think the button is not pushed
    {
        if (RC5_GetValue() == LOW) //see if the button is pushed
        {
            __delay_ms(100); //de-bouncing
            if (RC5_GetValue() == LOW) //if the button is still pressed
            {
                btn2State = PUSHED; //switch on button state
                switch2Event = 1; //raise the flag
            }
        }
    }
    
    else //we think the button is pushed
    {
        if (RC5_GetValue() == HIGH) //if the button is released
        {
            btn2State = NOT_PUSHED; //set the button state
        }
    }
}

void assignLight(void)
{
    
// if (switchEvent)
// {
// LED_D2_Toggle();
// switchEvent = 0;
// }
    
    if (switch2Event)
    {
        LED_D2_Toggle();
        switch2Event=0;
    }
    
// if(btnState == PUSHED) LED_D5_SetHigh();
// else LED_D5_SetLow();
    if(btn2State == PUSHED) LED_D4_SetHigh();
        else LED_D4_SetLow();
}
    
void blinkD3Fast(void)
{
    for(int i = 0 ; i<5 ; i++)
    {
        LED_D3_SetHigh();
        __delay_ms(500);
        LED_D3_SetLow();
        __delay_ms(500);
    }
}

void checkWin(void)
{
// if(btnState == PUSHED && btn2State == PUSHED)
// {
//
// winCount++;
// if(winCount>200) blinkD3Fast();
// if(winCount>20000)
// {
// blinkLight();
// }
// }
// else winCount = 0;
    
    if(btn2State == PUSHED)
    {
        winCount++;
        if(winCount>10000)
        {
            blinkD3Fast();
            Lcd_Clear();
            Lcd_Set_Cursor(1,1);
            Lcd_Print_String("Great Success");
            
            winCount = 0;
        }
    }
    else winCount = 0;
    
}

//void blinkLight(void)
//{
// blinking = 1;
// for(int i = 0 ; i<6 ; i++)
// {
// LATA = 0xFF;
// __delay_ms(500);
// LATA = 0x00;
// __delay_ms(500);
// }
// while(blinking)
// {
//
// LED_D2_SetHigh(); //long blink
// LED_D5_Toggle(); //longer blink
// __delay_ms(6000);
// LED_D2_SetLow();
// __delay_ms(1500);
//
// checkButtonS1(); //this would break the loop
// if(switchEvent)
// {
// blinking = 0;
// switchEvent = 0;
// }
// }
//}

void initLCD(void)
{
    Lcd_Start();
    __delay_ms(100);
    Lcd_Clear();
}

 
device config:
#ifndef DEVICE_CONFIG_H
#define DEVICE_CONFIG_H

#define _XTAL_FREQ 4000000

#endif /* DEVICE_CONFIG_H */

 
goLCD.h - LCD instructions and declarations (Edited in response to ric's comment):
 
#include <xc.h> // include processor files - each processor file is guarded. 


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
#define RS LATAbits.LATA0 // register select
#define RW LATAbits.LATA1 // read-write
#define EN LATAbits.LATA2 // enable
#define D0 LATBbits.LATB7
#define D1 LATBbits.LATB6
#define D2 LATBbits.LATB5
#define D3 LATBbits.LATB4
#define D4 LATBbits.LATB3
#define D5 LATBbits.LATB2
#define D6 LATBbits.LATB1
#define D7 LATBbits.LATB0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 


#define LCD_D LATB



void Lcd_SetBit(char data_bit) //Based on the Hex value Set the Bits of the Data Lines
{
 if(data_bit& 1)
  D4 = 1;
 else
  D4 = 0;

 if(data_bit& 2)
  D5 = 1;
 else
  D5 = 0;

 if(data_bit& 4)
  D6 = 1;
 else
  D6 = 0;

 if(data_bit& 8)
  D7 = 1;
 else
  D7 = 0;
}

void Lcd_Cmd(char a)
{
 RS = 0;
 Lcd_SetBit(a); //Incoming Hex value
 EN = 1;
        __delay_ms(4);
        EN = 0;
}

void Lcd_Clear(void)
{
 Lcd_Cmd(0); //Clear the LCD
 Lcd_Cmd(1); //Move the cursor to first position
}

void Lcd_Set_Cursor(char a, char b)
{
 char temp,z,y;
 if(a== 1)
 {
   temp = 0x80 + b - 1; //80H is used to move the cursor
  z = temp>>4; //Lower 8-bits
  y = temp & 0x0F; //Upper 8-bits
  Lcd_Cmd(z); //Set Row
  Lcd_Cmd(y); //Set Column
 }
 else if(a== 2)
 {
  temp = 0xC0 + b - 1;
  z = temp>>4; //Lower 8-bits
  y = temp & 0x0F; //Upper 8-bits
  Lcd_Cmd(z); //Set Row
  Lcd_Cmd(y); //Set Column
 }
}

void Lcd_Start()
{
  Lcd_SetBit(0x00);
  for(int i=1065244; i<=0; i--) NOP();
  Lcd_Cmd(0x03);
 __delay_ms(5);
  Lcd_Cmd(0x03);
 __delay_ms(11);
  Lcd_Cmd(0x03);
  Lcd_Cmd(0x02); //02H is used for Return home -> Clears the RAM and initializes the LCD
  Lcd_Cmd(0x02); //02H is used for Return home -> Clears the RAM and initializes the LCD
  Lcd_Cmd(0x08); //Select Row 1
  Lcd_Cmd(0x00); //Clear Row 1 Display
  Lcd_Cmd(0x0C); //Select Row 2
  Lcd_Cmd(0x00); //Clear Row 2 Display
  Lcd_Cmd(0x06);
}

void Lcd_Print_Char(char data) //Send 8-bits through 4-bit mode
{
   char Lower_Nibble,Upper_Nibble;
   Lower_Nibble = data&0x0F;
   Upper_Nibble = data&0xF0;
   RS = 1; // => RS = 1
   Lcd_SetBit(Upper_Nibble>>4); //Send upper half by shifting by 4
   EN = 1;
   for(int i=2130483; i<=0; i--) NOP();
   EN = 0;
   Lcd_SetBit(Lower_Nibble); //Send Lower half
   EN = 1;
   for(int i=2130483; i<=0; i--) NOP();
   EN = 0;
}

void Lcd_Print_String(char *a)
{
 int i;
 for(i=0;a[i]!='\0';i++)
    Lcd_Print_Char(a[i]); //Split the string using pointers and call the Char function
}

post edited by ishkabum - 2020/10/05 10:16:22
#1

27 Replies Related Threads

    mlp
    boots too small
    • Total Posts : 967
    • Reward points : 0
    • Joined: 2012/09/10 15:12:07
    • Location: previously Microchip XC8 team
    • Status: offline
    Re: Error related to program speed or timing with PIC18FQ47 2020/09/29 13:05:46 (permalink)
    0
    ishkabum
    I've integrated some code "goLCD.h" which was adapted from an online source.

    Were you planning on telling us which online source?
     
    I'm getting an error which I am guessing is something to do with timing.

    Were you planning on telling us which error?
    Were you planning on telling us how you guessed?
     
     

    Mark (this opinion available for hire)
    #2
    ishkabum
    Starting Member
    • Total Posts : 33
    • Reward points : 0
    • Joined: 2020/09/24 07:42:09
    • Location: 0
    • Status: offline
    Re: Error related to program speed or timing with PIC18FQ47 2020/09/29 13:18:29 (permalink)
    0
    This source:
     
    https://circuitdigest.com/microcontroller-projects/16x2-lcd-interfacing-with-pic-microcontroller
     
    Very sorry, I did intend to and forget to paste the exact error text. This is the compile output + error:
     
     
    *****************************************************

    Connecting to MPLAB PKoB4...
    Currently loaded versions:
    Application version............00.03.88
    Boot version...................01.01.00
    Script version.................00.03.77
    Script build number............648e375535
    Tool pack version .............1.1.166
    Target voltage detected
    Target device PIC18F47Q10 found.
    Device Revision Id = 0xa0040000
    Calculating memory ranges for operation...
    Erasing...
    The following memory area(s) will be programmed:
    program memory: start address = 0x0, end address = 0x7f
    program memory: start address = 0xf00, end address = 0x13ff
    configuration memory
    Verify failed. [ Pgm ] at 0x0, expected 0x0000ef9f, got 0x00000000
    You have set the program speed to Normal. The circuit on your board may require you to slow the speed down. Please change the setting in the tool properties to low and try the operation again.
    Programming did not complete.
     
    Build/Load output:
     
    make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
    make[1]: Entering directory 'C:/PROJECTS'
    make -f nbproject/Makefile-default.mk dist/default/production/PROJECTS.production.hex
    make[2]: Entering directory 'C:/PROJECTS'
    make[2]: 'dist/default/production/PROJECTS.production.hex' is up to date.
    make[2]: Leaving directory 'C:/PROJECTS'
    make[1]: Leaving directory 'C:/PROJECTS'
    BUILD SUCCESSFUL (total time: 62ms)
    Loading code from C:/PROJECTS/dist/default/production/PROJECTS.production.hex...
    Program loaded with pack,PIC18F-Q_DFP,1.8.154,Microchip
    Loading completed
    Connecting to programmer...
    Programming target...
    The programmer could not be started: Failed to program the target device
    #3
    ishkabum
    Starting Member
    • Total Posts : 33
    • Reward points : 0
    • Joined: 2020/09/24 07:42:09
    • Location: 0
    • Status: offline
    Re: Error related to program speed or timing with PIC18FQ47 2020/09/29 13:30:54 (permalink)
    0
    I changed the clock speed via a line in device_config.h to make __delay_ms() match a stopwatch. I wrote a blink routine and noticed that my 1 sec period was much faster so I tweaked it to define _XTAL_FREQ 4000000 making it match my stopwatch timing exactly. The purpose is to give myself the ability to use __delay_us and __delay_ms precisely in accordance with timing diagrams. Again sorry I didn't add this at first.
    post edited by ishkabum - 2020/09/29 13:37:16
    #4
    ric
    Super Member
    • Total Posts : 28660
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Error related to program speed or timing with PIC18FQ47 2020/09/29 13:38:01 (permalink)
    0
    This code is trying to control the data pins by just writing to the TRIS register.
    Why?
    That depends upon the data register being initialised to either 0x00 (and using external pullups), or 0xFF (and using external pulldowns). This code never writes anything to the data register.
    Is this trying to do some fancy voltage conversion with open collector drive?
    I'd start again, and control the pins via the LATx register, not TRISx.
     

    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
    ishkabum
    Starting Member
    • Total Posts : 33
    • Reward points : 0
    • Joined: 2020/09/24 07:42:09
    • Location: 0
    • Status: offline
    Re: Error related to program speed or timing with PIC18FQ47 2020/09/29 13:50:59 (permalink)
    0
    ric
    This code is trying to control the data pins by just writing to the TRIS register.
    Why?
    That depends upon the data register being initialised to either 0x00 (and using external pullups), or 0xFF (and using external pulldowns). This code never writes anything to the data register.

    Thank you for pointing this out, I changed to define the pins by LAT bits.
     
    ric
    Is this trying to do some fancy voltage conversion with open collector drive?
    I'd start again, and control the pins via the LATx register, not TRISx.
     

    No, basically all that's meant to happen is it's waiting for an S2 press. LED D5 responds to the press, and D3 toggles on the press. When it's held down long enough for the winCount to increment, it runs blinkD3Fast(). This I got to work before bringing in the LCD code. Now after running blinkD3Fast it's meant to clear the screen and show some text.

    The defines are now as follows:
    #define RS LATAbits.LATA0 // register select
    #define RW LATAbits.LATA1 // read-write
    #define EN LATAbits.LATA2 // enable
    #define D0 LATBbits.LATB7
    #define D1 LATBbits.LATB6
    #define D2 LATBbits.LATB5
    #define D3 LATBbits.LATB4
    #define D4 LATBbits.LATB3
    #define D5 LATBbits.LATB2
    #define D6 LATBbits.LATB1
    #define D7 LATBbits.LATB0

    #define LCD_D LATB

     
    TRISB = 0 in the beginning of the main file. Still getting these warnings that conversion from long to int changes value, and then I get:
     
    make[2]: Leaving directory 'C:/PROJECTS'
    make[1]: Leaving directory 'C:/PROJECTS'

    BUILD SUCCESSFUL (total time: 2s)
    Loading code from C:/PROJECTS/dist/default/production/PROJECTS.production.hex...
    Program loaded with pack,PIC18F-Q_DFP,1.8.154,Microchip
    Loading completed
    Connecting to programmer...
    Programming target...
    The programmer could not be started: Failed to program the target device

    post edited by ishkabum - 2020/09/29 13:56:44
    #6
    du00000001
    Just Some Member
    • Total Posts : 3978
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: Error related to program speed or timing with PIC18FQ47 2020/09/29 14:04:13 (permalink)
    0

    ...
    You have set the program speed to Normal. The circuit on your board may require you to slow the speed down. Please change the setting in the tool properties to low and try the operation again.
    ...

     
    This error message didn't target your software implementation - it targets the programming speed!
    So set the programming speed to one of the options slower than currently selected (somewhere in the project properties - related to the debugger used) and retry to program the uC!

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #7
    rperkel
    New Member
    • Total Posts : 1
    • Reward points : 0
    • Joined: 2020/08/04 09:23:45
    • Location: 0
    • Status: offline
    Re: Error related to program speed or timing with PIC18FQ47 2020/09/29 14:06:02 (permalink)
    0
    Verify failed. [ Pgm ] at 0x0, expected 0x0000ef9f, got 0x00000000
    You have set the program speed to Normal. The circuit on your board may require you to slow the speed down. Please change the setting in the tool properties to low and try the operation again.
    Programming did not complete.
     
    Is there anything connected to the ICSP lines? I have seen some programmer issues when something is loading down those lines. You may need to reassign the I/O or try programming with it disconnected. 
    #8
    ishkabum
    Starting Member
    • Total Posts : 33
    • Reward points : 0
    • Joined: 2020/09/24 07:42:09
    • Location: 0
    • Status: offline
    Re: Error related to program speed or timing with PIC18FQ47 2020/09/29 14:07:48 (permalink)
    0
    du00000001
     
    This error message didn't target your software implementation - it targets the programming speed!
    So set the programming speed to one of the options slower than currently selected (somewhere in the project properties - related to the debugger used) and retry to program the uC!


    I tried to set that to Low in the Program Options but I still get the following: 

     
    make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
    make[1]: Entering directory 'C:/PROJECTS'
    make -f nbproject/Makefile-default.mk dist/default/production/PROJECTS.production.hex
    make[2]: Entering directory 'C:/PROJECTS'
    "C:\Program Files\Microchip\xc8\v2.30\bin\xc8-cc.exe" -mcpu=18F47Q10 -c -mdfp="C:/Users/khalan nacht/.mchp_packs/Microchip/PIC18F-Q_DFP/1.8.154/xc8" -fno-short-double -fno-short-float -memi=wordwrite -O0 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=default -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -o build/default/production/mcc_generated_files/pin_manager.p1 mcc_generated_files/pin_manager.c
    "C:\Program Files\Microchip\xc8\v2.30\bin\xc8-cc.exe" -mcpu=18F47Q10 -c -mdfp="C:/Users/khalan nacht/.mchp_packs/Microchip/PIC18F-Q_DFP/1.8.154/xc8" -fno-short-double -fno-short-float -memi=wordwrite -O0 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=default -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -o build/default/production/mcc_generated_files/device_config.p1 mcc_generated_files/device_config.c
    "C:\Program Files\Microchip\xc8\v2.30\bin\xc8-cc.exe" -mcpu=18F47Q10 -c -mdfp="C:/Users/khalan nacht/.mchp_packs/Microchip/PIC18F-Q_DFP/1.8.154/xc8" -fno-short-double -fno-short-float -memi=wordwrite -O0 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=default -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -o build/default/production/mcc_generated_files/memory.p1 mcc_generated_files/memory.c
    "C:\Program Files\Microchip\xc8\v2.30\bin\xc8-cc.exe" -mcpu=18F47Q10 -c -mdfp="C:/Users/khalan nacht/.mchp_packs/Microchip/PIC18F-Q_DFP/1.8.154/xc8" -fno-short-double -fno-short-float -memi=wordwrite -O0 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=default -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -o build/default/production/mcc_generated_files/mcc.p1 mcc_generated_files/mcc.c
    "C:\Program Files\Microchip\xc8\v2.30\bin\xc8-cc.exe" -mcpu=18F47Q10 -c -mdfp="C:/Users/khalan nacht/.mchp_packs/Microchip/PIC18F-Q_DFP/1.8.154/xc8" -fno-short-double -fno-short-float -memi=wordwrite -O0 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=default -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -o build/default/production/main.p1 main.c
    In file included from main.c:12:
    ./goLCD.h:114:13: warning: implicit conversion from 'long' to 'int' changes value from 1065244 to 16668 [-Wconstant-conversion]
    for(int i=1065244; i<=0; i--) NOP();
    ~ ^~~~~~~
    ./goLCD.h:137:14: warning: implicit conversion from 'long' to 'int' changes value from 2130483 to -32205 [-Wconstant-conversion]
    for(int i=2130483; i<=0; i--) NOP();
    ~ ^~~~~~~
    ./goLCD.h:141:14: warning: implicit conversion from 'long' to 'int' changes value from 2130483 to -32205 [-Wconstant-conversion]
    for(int i=2130483; i<=0; i--) NOP();
    ~ ^~~~~~~
    3 warnings generated.
    "C:\Program Files\Microchip\xc8\v2.30\bin\xc8-cc.exe" -mcpu=18F47Q10 -Wl,-Map=dist/default/production/PROJECTS.production.map -DXPRJ_default=default -Wl,--defsym=__MPLAB_BUILD=1 -mdfp="C:/Users/khalan nacht/.mchp_packs/Microchip/PIC18F-Q_DFP/1.8.154/xc8" -fno-short-double -fno-short-float -memi=wordwrite -O0 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -Wl,--memorysummary,dist/default/production/memoryfile.xml -o dist/default/production/PROJECTS.production.elf build/default/production/mcc_generated_files/pin_manager.p1 build/default/production/mcc_generated_files/device_config.p1 build/default/production/mcc_generated_files/mcc.p1 build/default/production/mcc_generated_files/memory.p1 build/default/production/main.p1
    mcc_generated_files/pin_manager.c:128:: warning: (520) function "_PIN_MANAGER_IOC" is never called
    mcc_generated_files/memory.c:59:: warning: (520) function "_FLASH_ReadByte" is never called
    mcc_generated_files/memory.c:72:: warning: (520) function "_FLASH_ReadWord" is never called
    mcc_generated_files/memory.c:86:: warning: (520) function "_FLASH_ReadSector" is never called
    mcc_generated_files/memory.c:116:: warning: (520) function "_FLASH_WriteSector" is never called
    mcc_generated_files/memory.c:147:: warning: (520) function "_FLASH_WriteWord" is never called
    mcc_generated_files/memory.c:167:: warning: (520) function "_FLASH_WriteBlock" is never called
    mcc_generated_files/memory.c:194:: warning: (520) function "_FLASH_EraseBlock" is never called
    mcc_generated_files/memory.c:226:: warning: (520) function "_DATAEE_WriteByte" is never called
    mcc_generated_files/memory.c:259:: warning: (520) function "_DATAEE_ReadByte" is never called
    mcc_generated_files/memory.c:275:: warning: (520) function "_MEMORY_ISR" is never called
    ./goLCD.h:52:: warning: (520) function "_Lcd_SetBit" is never called
    ./goLCD.h:75:: warning: (520) function "_Lcd_Cmd" is never called
    ./goLCD.h:84:: warning: (520) function "_Lcd_Clear" is never called
    ./goLCD.h:90:: warning: (520) function "_Lcd_Set_Cursor" is never called
    ./goLCD.h:111:: warning: (520) function "_Lcd_Start" is never called
    ./goLCD.h:129:: warning: (520) function "_Lcd_Print_Char" is never called
    ./goLCD.h:145:: warning: (520) function "_Lcd_Print_String" is never called
    :0:: error: (499) undefined symbol:
    _initLCD(dist/default/production\PROJECTS.production.o)
    (908) exit status = 1
    nbproject/Makefile-default.mk:202: recipe for target 'dist/default/production/PROJECTS.production.hex' failed
    make[2]: Leaving directory 'C:/PROJECTS'
    nbproject/Makefile-default.mk:91: recipe for target '.build-conf' failed
    make[1]: Leaving directory 'C:/PROJECTS'
    nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
    make[2]: *** [dist/default/production/PROJECTS.production.hex] Error 1
    make[1]: *** [.build-conf] Error 2
    make: *** [.build-impl] Error 2
     
    BUILD FAILED (exit value 2, total time: 2s)
     
     

     
    I changed the _XTAL_FREQ definition to make the blink speed match a stopwatch so that I could use __delay_ms() accurately
    post edited by ishkabum - 2020/09/29 14:09:23
    #9
    du00000001
    Just Some Member
    • Total Posts : 3978
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: Error related to program speed or timing with PIC18FQ47 2020/09/29 14:59:28 (permalink)
    0
    Oh - EE student  :(
     
    Your current issue is "error: (499) undefined symbol -initLCD..."
     
    Might be a typo, might be a source file not included in the project configuration. (A file existing on the disk but not within the project configuration won't get compiled!)
    From the naming conventions of the other functions the missing one might exist as "Lcd_Init()".

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #10
    ishkabum
    Starting Member
    • Total Posts : 33
    • Reward points : 0
    • Joined: 2020/09/24 07:42:09
    • Location: 0
    • Status: offline
    Re: Error related to program speed or timing with PIC18FQ47 2020/09/29 15:05:51 (permalink)
    0
    I graduated long ago. It's just that I have not been working in embedded systems and am returning, so that's where my skills are now... That's where I set my expectations for understanding. I'm sorry man, I haven't done this in years and I'm trying to get better. I got laid off my job in building design and am re-entering this field where I have a lot of fun when things are working, so I'm attempting to build a device. I'm not in school.
     
    The initLCD() is different from Lcd_Init() and I did go ahead and comment out the call on initLCD to block this out of the code. Now at this point I have reduced my code to only the blinking example I had before. However now I've managed to mess up the clock, and though it does program the device, the response time is very low and the blink routine happens many times slower than it used to. I appreciate your help. The clock is currently set as such in device_config.h:
     
    #define _XTAL_FREQ 10000000

     
    The attached image shows how I'm setting the oscillator in MCC.
     
     
     
    This setting used to be fine (LED5 would instantly respond to button presses) and now there's some delay there, and I'm trying to resolve what's going on with the clock. Please let me know if any additional information will help. At this point I don't have any of the LCD code loaded and I'm just trying to get the timing on this LED routine back to working order. 
     
     
     
     
    post edited by ishkabum - 2020/09/29 15:21:34

    Attached Image(s)

    #11
    ric
    Super Member
    • Total Posts : 28660
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Error related to program speed or timing with PIC18FQ47 2020/09/29 15:19:20 (permalink)
    0
    You can't just drag an image from your PC into a post.
    You have to go "Open Full version" in the edit window, and attach the file.
     

    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!
    #12
    ishkabum
    Starting Member
    • Total Posts : 33
    • Reward points : 0
    • Joined: 2020/09/24 07:42:09
    • Location: 0
    • Status: offline
    Re: Error related to program speed or timing with PIC18FQ47 2020/09/29 15:22:53 (permalink)
    0
    ric
    You can't just drag an image from your PC into a post.
    You have to go "Open Full version" in the edit window, and attach the file.
     


    Thank you, I realized after I posted and was in the progress of adding the screenshot. Trust all I shall shed my repulsive noob skin and blossom into a full PIC star very shortly. I appreciate your patience :)
    post edited by ishkabum - 2020/09/29 15:26:37
    #13
    ric
    Super Member
    • Total Posts : 28660
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Error related to program speed or timing with PIC18FQ47 2020/09/29 15:44:45 (permalink)
    0
    Does the Curiosity board actually have an external oscillator connected to the PIC, or does it assume you are using a crystal or the internal oscillator?
    (Your config bits are specifying an external oscillator)
     

    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!
    #14
    ishkabum
    Starting Member
    • Total Posts : 33
    • Reward points : 0
    • Joined: 2020/09/24 07:42:09
    • Location: 0
    • Status: offline
    Re: Error related to program speed or timing with PIC18FQ47 2020/09/29 16:57:56 (permalink)
    0
    Good point. Even if there were, which I don't think there is, I wouldn't want to use it. It still has the delay before registering button push given the following:

    Attached Image(s)

    #15
    ric
    Super Member
    • Total Posts : 28660
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Error related to program speed or timing with PIC18FQ47 2020/09/29 17:02:19 (permalink)
    +1 (1)
    The very next CONFIG item is setting it to a 1MHz internal oscillator, which is pretty slow.
    There are faster options available.
     

    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!
    #16
    du00000001
    Just Some Member
    • Total Posts : 3978
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: Error related to program speed or timing with PIC18FQ47 2020/09/29 18:02:08 (permalink)
    +1 (1)
    The worst thinh is that you currently seem to use a 1 MHz (1 + 6 zeros) internal oscillator while your definition of _XTAL_FREQ is a 1 + 7 zeros - 10 MHz. What do you expect from the delay* macros?
    I assume your software is currently running at 1/10th of the intended speed  :)
     
    BTW: where is the LCD code from? Arm? (The int size of the LCD code seems to be 32- Bit while the int size of the PIC18 is 16-Bit. Thus the list of warnings about type conflicts / value truncation.

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #17
    ishkabum
    Starting Member
    • Total Posts : 33
    • Reward points : 0
    • Joined: 2020/09/24 07:42:09
    • Location: 0
    • Status: offline
    Re: Error related to program speed or timing with PIC18FQ47 2020/09/29 19:51:33 (permalink)
    0
    OK this is all appreciated and I've changed it to aim for 8 MHz. 
     
    I got this timing part to work relating to buttons & LEDs by resetting the clock.
     
    Thanks again for your help and I will begin re-integrating that LCD code, but I will look at this 32-bit int situation. The code is from this page using PIC16F877A with MPLAB X IDE, XC8 compiler:
     
    https://circuitdigest.com/microcontroller-projects/16x2-lcd-interfacing-with-pic-microcontroller
     
     
    post edited by ishkabum - 2020/09/29 20:06:19

    Attached Image(s)

    #18
    ric
    Super Member
    • Total Posts : 28660
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Error related to program speed or timing with PIC18FQ47 2020/09/29 20:05:18 (permalink)
    0
    ishkabum
    The "Generate Source Code to Output" button is shown along with Config Bits settings in the second screenshot.
     

    What's your point?
    It will show old values until you have done a successful compile.
     

    I still have somewhere a reference to the old file 'configbitss.h' apparently. 

    Why do you say this?
    Is there a message about that file somewhere?
     

    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!
    #19
    ishkabum
    Starting Member
    • Total Posts : 33
    • Reward points : 0
    • Joined: 2020/09/24 07:42:09
    • Location: 0
    • Status: offline
    Re: Error related to program speed or timing with PIC18FQ47 2020/09/29 20:09:07 (permalink)
    0
    ric
    What's your point?
    It will show old values until you have done a successful compile.
     

    Just wanted to make it clear how I'm arriving at the current state. 
     
    ric
    Why do you say this?
    Is there a message about that file somewhere?
      

     
    Yes it gave me an error about that. But I did get it to compile properly once I deleted the old main.p1, main.i, and main.p1.d from build/default/production/ within the project directory. Now I will try to re-add the LCD code and make sure that ints are the right size.
     
    post edited by ishkabum - 2020/09/29 20:12:51
    #20
    Page: 12 > Showing page 1 of 2
    Jump to:
    © 2020 APG vNext Commercial Version 4.5