|
|
View previous topic :: View next topic |
Author |
Message |
samu350
Joined: 27 Jan 2019 Posts: 9
|
Problem with GLCD.C driver [Solved] |
Posted: Mon Jan 28, 2019 1:09 pm |
|
|
Currently trying to use the GLCD.C driver with the dsPIC33EP512MC806.
I keep getting the error "Function used but not defined" in the glcd_writeByte function. I know I'm not allowed to post drivers here so I'll just post my current main code and fuses.
Quote: | #include <33EP512MC806.h>
#device ICSP=1
#include <glcddspic.c>
#include <graphics.c>
#include <math.h>
#use delay(internal=19960417)
#word RPINR0 = 0x06A0
#word RPINR1 = 0x06A2
#FUSES NOWDT //No Watch Dog Timer
#FUSES CKSFSM //Clock Switching is enabled, fail Safe clock monitor is enabled
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOJTAG //JTAG disabled
#DEFINE DELAY 150
|
I'm not using absolutely anything else, I do know that the dspic works with int 16 so I don't know if this might be causing the problem. But it keeps saying that the function doesn't exist although I've changed my data bus, CS1,CS2 and related pins in the library.
Last edited by samu350 on Thu Jan 31, 2019 2:35 pm; edited 1 time in total |
|
|
newguy
Joined: 24 Jun 2004 Posts: 1907
|
|
Posted: Mon Jan 28, 2019 1:28 pm |
|
|
The problem is where in your code you're including the drivers. The compiler is a single pass compiler remember - that means that, in order, it needs to see either a complete function definition before it is used in code, or it needs to see a function declaration first, then it can be used somewhere, then finally it can be defined.
By including the drivers where you did, the compiler is encountering glcd_writeByte() in use somewhere in the driver. It's telling you that hey, I found this function glcd_writeByte() in the middle of the code but you didn't tell me what it does.....yet.
See if those drivers have header files - include them FIRST. If not, it's up to you to create a "declarations.h" file, declare all global variables and functions there, include it FIRST in your program, then include the drivers that come with the compiler.
Also, it's better form to include any drivers (compiler-supplied or your own files) AFTER the fuses.
Code: | #include <processor.h> // this is first
#device directives next
#use clock next
#fuses here
additional #use whatevers follow the fuses (sometimes UART or CAN or whatever defines depend on #fuses specific to peripheral pins, so those must come first)
#includes for headers, drivers, etc here
main {
// device config, variable config here
while (TRUE) {
// meat & potatoes project code here
}
} |
|
|
|
samu350
Joined: 27 Jan 2019 Posts: 9
|
|
Posted: Mon Jan 28, 2019 9:53 pm |
|
|
Sorry for the late reply, internet went down for quite some time. My problem was that the function inside the driver had a wrong value type parameter. The solution was to set it to BYTE instead of CHAR, this instantly solved the problem. Thanks a lot for the help! :D |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19499
|
|
Posted: Tue Jan 29, 2019 4:09 am |
|
|
This is actually because you are on the DsPIC.
Normally (PIC16 & 18), byte and char are completely interchangeable.
However on the DsPIC's, a 'byte', is defined as an 'unsigned int8', while
a char is just defined as an 'int8', which on the DsPIC defaults to signed.
Hence the problem....
You would be better to set everything to byte, rather than char otherwise
some things that may use values>127 may have issues... |
|
|
samu350
Joined: 27 Jan 2019 Posts: 9
|
|
Posted: Tue Jan 29, 2019 5:07 pm |
|
|
Ttelmah wrote: | This is actually because you are on the DsPIC.
Normally (PIC16 & 18), byte and char are completely interchangeable.
However on the DsPIC's, a 'byte', is defined as an 'unsigned int8', while
a char is just defined as an 'int8', which on the DsPIC defaults to signed.
Hence the problem....
You would be better to set everything to byte, rather than char otherwise
some things that may use values>127 may have issues... |
Thanks! That's definitely a better explanation of my problem, my school partner was the one to find the issue and he pointed this out. It seems that that was the only instance to use CHAR instead of BYTE so it was all good . |
|
|
|
|
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
|