• AVR Freaks

Hot!Defining a TRISB bit wont compile

Author
flavinm
New Member
  • Total Posts : 2
  • Reward points : 0
  • Joined: 2016/06/30 19:30:12
  • Location: 0
  • Status: offline
2020/04/07 13:49:57 (permalink)
0

Defining a TRISB bit wont compile

I am trying to port a program form Mikroe C and I am having some issues.  Most everything is ok with a couple of exceptions
 
It says ST7735_driver.c:42: error: (192) undefined identifier "TRISBbits"
 
I have the following defined
 
#define DISP_CS TRISBbits.TRISB1 
#define DISP_DC TRISBbits.TRISB2 
#define DISP_RES TRISBbits.TRISB0
#define DISP_SDIN TRISBbits.TRISB3 
#define DISP_SCLK TRISBbits.TRISB4
 
it also gives me this
 
ST7735_driver.c:44: error: (196) struct/union required
 
 
It also gives me a bunch of these
 
main.c:304: warning: (361) function declared implicit int for alot of funtions
 
Using PIC 18F25k22
 
I have included
 
#include <stdio.h>
#include <stdlib.h>
#include <p18cxxx.h>
#include <xc.h>
#include <htc.h>
 
All of this compiled with no errors before so I suppose it is something to do with some syntax but I have not been able to figure it out
 
Any help appreciated
 
 
 
 
#1

5 Replies Related Threads

    katela
    Super Member
    • Total Posts : 1745
    • Reward points : 0
    • Joined: 2013/06/11 05:25:18
    • Location: South Africa
    • Status: offline
    Re: Defining a TRISB bit wont compile 2020/04/09 08:39:18 (permalink)
    +1 (1)
    Can you post your full project or a small version of your project that replicate the same problem?
    Can you post the full error logs?
    You also don't need #include <p18cxxx.h> , #include <xc.h> takes care of that.

    Free online Microcontroller Tutorials and Projects for Hobbyists and students. From beginners to advanced. Website: www.studentcompanion.co.za
    YouTube Tutorials: https://www.youtube.com/StudentCompanionSA
    #2
    NKurzman
    A Guy on the Net
    • Total Posts : 18655
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: Defining a TRISB bit wont compile 2020/04/09 10:43:46 (permalink)
    +1 (1)
    You do not need #include <htc.h> either, <xc.h> replaced it.
     
    Can we assume #include <xc.h> is before the #defines?
    #3
    ric
    Super Member
    • Total Posts : 26942
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Defining a TRISB bit wont compile 2020/04/09 16:51:37 (permalink)
    +1 (1)
    As others have said, you only need to include xc.h, not htc.h or p18cxxx.h
    and xc.h must be included BEFORE you try to define pins.
    You almost certainly don't need stdio.h, and may not need stdlib.h either.
    Get out of the habit of #including a swathe of libraries that are only needed on Windows.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #4
    pcbbc
    Super Member
    • Total Posts : 1687
    • Reward points : 0
    • Joined: 2014/03/27 07:04:41
    • Location: 0
    • Status: offline
    Re: Defining a TRISB bit wont compile 2020/04/09 18:11:44 (permalink)
    +1 (1)
    ric
    and xc.h must be included BEFORE you try to define pins.

    Ideally for clarity, but it’s not a requirement.
    No syntax checking occurs on #define until the point at which it is actually used and expanded.
    #5
    ric
    Super Member
    • Total Posts : 26942
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Defining a TRISB bit wont compile 2020/04/09 18:21:24 (permalink)
    0
    pcbbc
    ric
    and xc.h must be included BEFORE you try to define pins.

    Ideally for clarity, but it’s not a requirement.
    No syntax checking occurs on #define until the point at which it is actually used and expanded.

    You're absolutely correct.

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #6
    Jump to:
    © 2020 APG vNext Commercial Version 4.5