Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[General] Need help in MplabX and pic24f

Status
Not open for further replies.
Proteus Sample Designs have Explorer 16 Board which has PIC24FJ. Use it to simulate your Projects.
 

i trying with this code but he display mean error in fucnction
Code:
void lcd_delay() { mSecDelay(2); }  // if LCD does not work make this longer
XC16 has a delay function, e.g. use
Code:
#include <libpic30.h>
void __delay_ms(unsigned int time);
and i dont have this file .h
Code:
#include "hardware.h"
#include "lcd.h"
thanks in advance
remove them - they are used in the rest of my project
 
  • Like
Reactions: ings

    ings

    Points: 2
    Helpful Answer Positive Rating
Plz Milan you talk about ISIS ? or another simulator because in ISIS i dnt find Explorer 16?

- - - Updated - - -

Horace i m adding this include but i have the ame error with LCD_Delay
 

Horace i m adding this include but i have the ame error with LCD_Delay

replace the call to lcd_delay() with __delay_ms()
lcd_delay() is one of my own functions driven by a timer interrupt
 
  • Like
Reactions: ings

    ings

    Points: 2
    Helpful Answer Positive Rating
but you have definned this function 2*
void __delay_ms(unsigned int time);
void __delay_ms() { mSecDelay(2);
so i m delete one of these finction but he display me a error in delay_ms
 

as __delay_ms() uses loops for the delay you need to specify the clock frequency
e.g. this compiles OK with XC8
Code:
    #include <xc.h>        /* XC8 General Include File */
#define _XTAL_FREQ 400000
int main(void)
{

            __delay_ms(100);
}
 
  • Like
Reactions: ings

    ings

    Points: 2
    Helpful Answer Positive Rating
yes i have defined the fCY but the same error with delay_ms
 

delay_ms is defined twise

- - - Updated - - -

main.c: In function '__delay_ms':
main.c:38:1: error: number of arguments doesn't match prototype
i thos line
Code:
void __delay_ms() { mSecDelay(2); }

- - - Updated - - -

i delete
Code:
void __delay_ms(unsigned int time);

- - - Updated - - -

and when i delete
Code:
void __delay_ms() { mSecDelay(2); }
he displa me this error
main.c: In function 'lcdNibble':
main.c:50:9: warning: unused variable 'lcd'
main.c: In function 'main':
main.c:45:1: warning: control reaches end of non-void function
 

in my original code replace this function
Code:
void lcd_delay() { mSecDelay(2); }
with
Code:
#include <xc.h>        /* XC8 General Include File */
#define _XTAL_FREQ 400000    // replace with your frequency

void lcd_delay() { __delay_ms(2); }  //
 
  • Like
Reactions: ings

    ings

    Points: 2
    Helpful Answer Positive Rating
the error now is :
build/default/production/main.o(.text+0x6): In function `.LSM1':
: undefined reference to `___delay_ms'
make[2]: *** [dist/default/production/LCD_pic24f_hello.X.production.hex] Error 255
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
 

yes
but is it ot necssarry to addd the configuation of bits or it is not important?
 

yes
but is it ot necssarry to addd the configuation of bits or it is not important?

you need the configuration bits to set up the oscillator, watchdog times, etc
you can see the defualt settings under Window > PIC Memory Views > Configuration Bits and generate an output file from them to include in your code for modification

see
https://microchip.wikidot.com/mplabx:view-and-set-configuration-bits
https://singularengineer.com/programming-pic-18-using-xc8-mplab-x-configuration-bits-2/
 
Last edited:
  • Like
Reactions: ings

    ings

    Points: 2
    Helpful Answer Positive Rating
i m adding this configuration of the bits but alo he dont workand aloso the poble with delay_ms
build/default/production/main.o(.text+0x6): In function `.LSM1':
: undefined reference to `___delay_ms'build/default/production/main.o(.text+0x6): In function `.LSM1':
: undefined reference to `___delay_ms'
another question plz iff i want o test my programm with startt kit directly i dont need any programmer (icd2 or icd3), i can directly send my programm in pic24f starter kit and test my program in the kit or it is a abligation to hve icd3?
 

in this file my project in mplabx and isis i hope that yo will find tis error
 

Attachments

  • forum.rar
    39.5 KB · Views: 73

looked at header libpic30.h and the "16-Bit Language Tools Libraries Reference Manual” and rather than XTAL_FREQ (required for XC8) it requires FCY instruction frequency to be defined before including it
e.g.
Code:
#define FCY 400000
#include <libpic30.h>
also in main() should
Code:
   LCD_Out(1,1,"LCD Test...");
be
Code:
    lcdString(1,1,"LCD Test...");
 
  • Like
Reactions: ings

    ings

    Points: 2
    Helpful Answer Positive Rating
in this case we have this error :
main.c:38:6: error: expected identifier or '(' before '{' token
main.c: In function 'main':
main.c:181:5: warning: pointer targets in passing argument 3 of 'lcdString' differ in signedness
main.c:115:6: note: expected 'unsigned char *' but argument is of type 'char *'
make[2]: *** [build/default/production/main.o] Error 255
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
nbproject/Makefile-default.mk:94: recipe for target 'build/default/production/main.o' failed

BUILD FAILED (exit value 2, total time: 460ms)

in thi 2 line
Code:
void __delay_ms(unsigned int time);
    lcdCmd(_LCD_CLEAR);
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top