EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / Error 1151 struct or union object designator expected

Error 1151 struct or union object designator expected

|

Microcontroller › PIC › Error 1151 struct or union object designator expected

  • This topic has 1 reply, 1 voice, and was last updated 13 years, 3 months ago by kasoma.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • March 10, 2012 at 6:00 pm #1587
    kasoma
    Participant

    Hullo everyone

    Thank you for your participation on this forum

     

    I  want to interface a PIC81F4550 with an LCD (16×2).

    I am using MPLAB with C18 compiler to write my source code. I got an error(error 1151) that struct or object designator expected

    When I looked up the error in the MPLAB CI8  users guide I found this message

    “1151: struct or union object designator expected
    The member access operators, ‘.’ and ‘->’ require operands of struct/union
    and pointer to struct/union, respectively.”

     I think the library function miss some operands  but I don’t really know how to  include those operands.

     

    Please help me debug this code because I need it for my final year project.

     

     Here is the source code

     

    #include <p18cxxx.h>
    #pragma config CPUDIV = OSC1_PLL2
    #pragma config WDT = OFF
    #pragma config LVP = OFF
    #pragma config DEBUG = OFF
    #pragma config MCLRE = ON
    //static bit LCD_RS    @ ((unsigned)&PORTA*8+4)
    //static bit LCD_EN    @ ((unsigned)&PORTA*8+5)
    #define LCD_RS LATABits.LATB4
    #define LCD_EN LATABits.LATB5
    //#define LCD_RS LATA.F4
    //#define LCD_EN LATA.F5
    #define LCD_STROBE ((LCD_EN = 1), (LCD_EN = 0))

    //void lcd_write (unsigned char);
    //void lcd_clear (void);
    //void lcd_puts(const char * s);
    //void lcd_goto(unsigned char pos);

    void main(void)
    {
    void lcd_init (void);
    LATA = 0x00;
    TRISA = 0x00;
    LATB = 0x00;
    TRISB = 0x00;
     lcd_init();
    }

    void lcd_init(void)
    {
        LCD_RS = 0;    // write control bytes
        DelayMs(15);    // power on delay
        PORTB = 0x3;    // attention!
        LCD_STROBE;
        DelayMs(5);
        LCD_STROBE;
     DelayUs(100);
    //    LCD_STROBE;
        LCD_EN = 1;
        LCD_EN = 0;
        DelayMs(5);
        PORTB = 0x2;    // set 4 bit mode
        LCD_STROBE;
     DelayUs(40);
        lcd_write(0x28);    // 4 bit mode, 1/16 duty, 5×8 font
        lcd_write(0x08);    // display off
        lcd_write(0x0F);    // display on, blink curson on
        lcd_write(0x06);    // entry mode
    }

     

    ON BUILDING THESE ARE THE RESULTS

     

    Debug build of project `C:Userstx2AKEDocumentsPICworksdisplay.mcp’ started.
    Language tool versions: mpasmwin.exe v5.42, mplink.exe v4.40, mcc18.exe v3.40, mplib.exe v4.40
    Preprocessor symbol `__DEBUG’ is defined.
    Sat Mar 10 20:58:22 2012



    Clean: Deleting intermediary and output files.
    Clean Warning: File “C:Userstx2AKEDocumentsPICworksdisplay2.o” doesn’t exist.
    Clean: Deleted file “C:Userstx2AKEDocumentsPICworksdisplay.mcs”.
    Clean: Done.
    Executing: “C:MCC 18binmcc18.exe” -p=18F4450 /i”C:MCC 18h” “display.c” -fo=”display.o” -D__DEBUG -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa-
    C:Userstx2AKEDocumentsPICworksdisplay.c:55:Error [1203] too few arguments in function call
    C:Userstx2AKEDocumentsPICworksdisplay.c:57:Error [1203] too few arguments in function call
    C:Userstx2AKEDocumentsPICworksdisplay.c:67:Error [1151] struct or union object designator expected
    C:Userstx2AKEDocumentsPICworksdisplay.c:67:Error [1151] struct or union object designator expected
    C:Userstx2AKEDocumentsPICworksdisplay.c:69:Error [1151] struct or union object designator expected
    C:Userstx2AKEDocumentsPICworksdisplay.c:69:Error [1151] struct or union object designator expected
    C:Userstx2AKEDocumentsPICworksdisplay.c:70:Warning [2058] call of function without prototype
    C:Userstx2AKEDocumentsPICworksdisplay.c:80:Error [1151] struct or union object designator expected
    C:Userstx2AKEDocumentsPICworksdisplay.c:82:Warning [2058] call of function without prototype
    C:Userstx2AKEDocumentsPICworksdisplay.c:89:Error [1151] struct or union object designator expected
    C:Userstx2AKEDocumentsPICworksdisplay.c:100:Error [1151] struct or union object designator expected
    C:Userstx2AKEDocumentsPICworksdisplay.c:108:Error [1151] struct or union object designator expected
    C:Userstx2AKEDocumentsPICworksdisplay.c:109:Warning [2058] call of function without prototype
    C:Userstx2AKEDocumentsPICworksdisplay.c:111:Error [1151] struct or union object designator expected
    C:Userstx2AKEDocumentsPICworksdisplay.c:111:Error [1151] struct or union object designator expected
    C:Userstx2AKEDocumentsPICworksdisplay.c:112:Warning [2058] call of function without prototype
    C:Userstx2AKEDocumentsPICworksdisplay.c:113:Error [1151] struct or union object designator expected
    C:Userstx2AKEDocumentsPICworksdisplay.c:113:Error [1151] struct or union object designator expected
    C:Userstx2AKEDocumentsPICworksdisplay.c:114:Warning [2058] call of function without prototype
    C:Userstx2AKEDocumentsPICworksdisplay.c:115:Error [1151] struct or union object designator expected
    C:Userstx2AKEDocumentsPICworksdisplay.c:115:Error [1151] struct or union object designator expected
    C:Userstx2AKEDocumentsPICworksdisplay.c:116:Warning [2058] call of function without prototype
    C:Userstx2AKEDocumentsPICworksdisplay.c:118:Error [1151] struct or union object designator expected
    C:Userstx2AKEDocumentsPICworksdisplay.c:118:Error [1151] struct or union object designator expected
    C:Userstx2AKEDocumentsPICworksdisplay.c:119:Warning [2058] call of function without prototype
    Halting build on first failure as requested.



    Debug build of project `C:Userstx2AKEDocumentsPICworksdisplay.mcp’ failed.
    Language tool versions: mpasmwin.exe v5.42, mplink.exe v4.40, mcc18.exe v3.40, mplib.exe v4.40
    Preprocessor symbol `__DEBUG’ is defined.
    Sat Mar 10 20:58:23 2012



    BUILD FAILED

    March 11, 2012 at 5:22 pm #7287
    kasoma
    Participant

    EUREKA!

     

    Hullo everyone. I got the cause of the error [1151] struct or union object designator expected.

    The naming of the ports was not inline with the names used in the C18 header files.

    The C18 compiler provides a header file with definitions for ports and pins for each microcontroller it supports. The default
    directory for these files is C:MCC18h . For example, the 18F4550 file includes the following code:
    extern volatile near unsigned char PORTB;
    extern volatile near union {
    struct {
    unsigned RB0:1;
    unsigned RB1:1;
    unsigned RB2:1;
    unsigned RB3:1;
    unsigned RB4:1;
    unsigned RB5:1;
    unsigned RB6:1;
    unsigned RB7:1;
    };
    struct {
    unsigned INT0:1;
    unsigned INT1:1;
    unsigned INT2:1;
    };
    struct {
    unsigned :5;
    unsigned PGM:1;
    unsigned PGC:1;
    unsigned PGD:1;
    };
    } PORTBbits;
    This code shows the various ways of addressing PORT B pins. For example, they can be addressed as a byte by PORTB, or
    as individual pins by the union PORTBbits using PORTBbits.RB0 through PORTBbits.RB7. When set up as interrupts, pins
    0-2 should be accessed as PORTBbits.INT0 through PORTBbits.INT2.

    therefore instead of
    #define rs LATA.F4
    #define en LATA.F5
    I should use
    # define rs PORTAbits.RB4
    #define en PORTAbits.RB5

    Do you understand that? I ‘ve learnt that when programming you don’t need to figit. just relax and do things without panicing.
    Thank you

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • PIC KIT 3 not able to program dsPIC June 19, 2025
  • Back to the old BASIC days June 19, 2025
  • using a RTC in SF basic June 19, 2025
  • what's it's name June 19, 2025
  • What is correct names for GOOD user friendly circuit drawing program? June 18, 2025

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise