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 / Replies / EUREKA! Hullo everyone. I got

EUREKA! Hullo everyone. I got

|

Microcontroller › PIC › Error 1151 struct or union object designator expected › EUREKA! Hullo everyone. I got

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

RSS Recent Posts

  • Panasonic RQ-A170 Walkman recorder November 7, 2025
  • strange laptop problem November 7, 2025
  • WTB: "The Theory Of Servicing AM, FM, And FM Receivers" by Clarence R. Green and Robert M. Bourque November 7, 2025
  • Converting 1vac to 24vac November 7, 2025
  • AC Input Relay Device Required November 7, 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