Problem with Hi tech C and pic18f4550+lcd

Status
Not open for further replies.

cyrus88

New Member
hi guy, i get “can’t generate code for this expression” when compile using hi tech c. it point me to "(char str[5]={0,0,0,0,0}" when i double click the error. this the bug of the compiler or the program problem.

here is what the code i am trying
Interfacing LCD Modules with PIC Microcontrollers. | eXtreme Electronics


btw, anyone have LCD (jhd162a, i think is compatible with HD447800 ) library that using Hi tech c (newbie in pic18, hi tech c is the only compiler i know)....i had try few library file, but none of it work, hope anyone can share with me. rushing my project T.T .

i am using pic18f4550 + 20MHZ crystal clock.



appreciate for the help from anyone....thanks.


LCD.c
 
Last edited:
Try taking the 5 out of the array so it's open ended. Not sure if that will work, but it does on some compilers.
 
Just change that line to:
char str[5];

the array gets populated in the while loop 2 lines later
 
The link you posted doesn't have the line you mentioned. Post the entire program code, because C sometimes generates error messages for lines other than the problem line.
 
Are you accually trying to put brackests () around the definition?
Code:
"(char str[5]={0,0,0,0,0};)"

Should be like this
Code:
char str[5]={0,0,0,0,0};
 
If you download the code in the link the OP posted you'll see that the array gets populated in a while loop 2 lines later. In the code it does not have the () and it compiles just fine if you change the line to:
char str[5];

It the array needs initializing, you can do it in a separate loop, eg:
Code:
for (x = 0;x<5;x++)
{
  str[x] = 0;
}
 
Last edited:
Just change that line to:
char str[5];

the array gets populated in the while loop 2 lines later

cannot, i get error when compile....
Error [195] C:\Users\YenFeng\Documents\Downloads\PIC18_LCDlib\PIC18_LCDlib\lcd_test\lcd.c; 240.13 expression syntax
Error [312] C:\Users\YenFeng\Documents\Downloads\PIC18_LCDlib\PIC18_LCDlib\lcd_test\lcd.c; 240.24 ";" expected...........................

Are you accually trying to put brackests () around the definition?
there is no brackets in the program, i put brackets in here to highlight it. sorry for make you guy confuse.

The link you posted doesn't have the line you mentioned. Post the entire program code, because C sometimes generates error messages for lines other than the problem line.
the code is in the download file there, i will post all the code here...
 
Last edited:
sorry, after change it char str[5], the code now can compile already, but not sure it can work or not, there is only one row of square box show up, nothing else....

btw anyone can show me how to set the configuration bit correctly? i am using the configuration bit of the USB bootloader.
i not dare to set the configuration bit, coz it might spoil my USB bootloader..
 
Last edited:
you may need to include the code I posted earlier to initialize the values in the array all to "0"
as for changing configuration bits, what are you looking to change from the program that was provided?
USB power from your laptop should work just fine.
 
something strange happen with my PDFSUSB....when i flash other code no problem, but it keep error when i flash this code....had to use export in mplab....anyone face this problem before?

btw, i have a question about the configuration bit. if i did not set any configuration bit in my program, the controller will run using the usb bootloader configuration bit?
 
the code is work if i flash using the pic18 programmer, but if i load using USB bootloader either i click yes to use the code configuration bit(i simply set) and my usb bootloader will stop working or i click no the program can flash, but didn't not work.....who can tell me which configuration bit i should pay attention to let my code run with the usb bootloader......sorry for my bad english...
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…