1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

Problem with Hi tech C and pic18f4550+lcd

Discussion in 'Microcontrollers' started by cyrus88, Feb 26, 2010.

  1. cyrus88

    cyrus88 New Member

    Joined:
    Feb 26, 2010
    Messages:
    6
    Likes:
    0
    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: Feb 26, 2010
  2. smanches

    smanches New Member

    Joined:
    Mar 5, 2009
    Messages:
    986
    Likes:
    8
    Location:
    Oregon, USA
    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.
     
  3. Norlin

    Norlin New Member

    Joined:
    May 9, 2007
    Messages:
    245
    Likes:
    3
    Location:
    Lawrenceville, NJ
    Just change that line to:
    char str[5];

    the array gets populated in the while loop 2 lines later
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. upand_at_them

    upand_at_them Member

    Joined:
    Apr 23, 2005
    Messages:
    609
    Likes:
    8
    Location:
    Pennsylvania, U.S.

    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.
     
  6. bugtraker

    bugtraker New Member

    Joined:
    Feb 26, 2010
    Messages:
    1
    Likes:
    0
    Are you accually trying to put brackests () around the definition?
    Code (text):
    "(char str[5]={0,0,0,0,0};)"
    Should be like this
    Code (text):
    char str[5]={0,0,0,0,0};
     
  7. Norlin

    Norlin New Member

    Joined:
    May 9, 2007
    Messages:
    245
    Likes:
    3
    Location:
    Lawrenceville, NJ
    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 (text):

    for (x = 0;x<5;x++)
    {
      str[x] = 0;
    }
     
     
    Last edited: Feb 26, 2010
  8. cyrus88

    cyrus88 New Member

    Joined:
    Feb 26, 2010
    Messages:
    6
    Likes:
    0
    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...........................

    there is no brackets in the program, i put brackets in here to highlight it. sorry for make you guy confuse.

    the code is in the download file there, i will post all the code here...
     
    Last edited: Feb 26, 2010
  9. cyrus88

    cyrus88 New Member

    Joined:
    Feb 26, 2010
    Messages:
    6
    Likes:
    0
    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: Feb 26, 2010
  10. cyrus88

    cyrus88 New Member

    Joined:
    Feb 26, 2010
    Messages:
    6
    Likes:
    0
    i am using USB port of my laptop to power my circuit, this will be the problem?
     
  11. Norlin

    Norlin New Member

    Joined:
    May 9, 2007
    Messages:
    245
    Likes:
    3
    Location:
    Lawrenceville, NJ
    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.
     
  12. cyrus88

    cyrus88 New Member

    Joined:
    Feb 26, 2010
    Messages:
    6
    Likes:
    0
    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?
     
  13. cyrus88

    cyrus88 New Member

    Joined:
    Feb 26, 2010
    Messages:
    6
    Likes:
    0
    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...
     

Share This Page