Definitions

Discuss about beta versions of mikroC compiler.
Post Reply
Author
Message
anton
Posts: 807
Joined: 23 Sep 2004 09:16
Location: South-Africa
Contact:

Definitions

#1 Post by anton » 24 Apr 2006 16:36

Hello again,

Please help me understand this. Looks like the compiler supports records in the definition file. But if I understand it correct, if you want to say

Code: Select all

LatBBits.LatB0 = 1
then this is not correct

Code: Select all

register volatile unsigned int LATB absolute 0x02CA; 
typedef struct tagLATBBITS {
        unsigned LATB0  :1;
        unsigned LATB1  :1;
        unsigned LATB2  :1;
        unsigned LATB3  :1;
        unsigned LATB4  :1;
        unsigned LATB5  :1;
        unsigned LATB6  :1;
        unsigned LATB7  :1;
        unsigned LATB8  :1;
        unsigned LATB9  :1;
        unsigned LATB10 :1;
        unsigned LATB11 :1;
        unsigned LATB12 :1;
        unsigned        :3;
} LATBBITS;
and must be

Code: Select all

register volatile unsigned int LATB absolute 0x02CA; 
typedef struct tagLATBBITS {
        unsigned LATB0  :0;
        unsigned LATB1  :1;
        unsigned LATB2  :2;
        unsigned LATB3  :3;
        unsigned LATB4  :4;
        unsigned LATB5  :5;
        unsigned LATB6  :6;
        unsigned LATB7  :7;
        unsigned LATB8  :8;
        unsigned LATB9  :9;
        unsigned LATB10 :10;
        unsigned LATB11 :11;
        unsigned LATB12 :12;
} LATBBITS;
:roll: :roll:

Anton
Another proud user of LV 24-33A Development System and mikroPascal PRO for dsPIC :)
PortA not working? Add CMCON := 7; PortD not working? Add ADCON1 := 6;
To paste code on the forum, please use the [b] Code [/b] button !! ;)

jpc
Posts: 1986
Joined: 22 Apr 2005 17:40
Location: France 87

#2 Post by jpc » 24 Apr 2006 17:32

If you look at the definition-files for the dsPIC-Pascal you will find the same

Code: Select all

// LATB: Port B Latch Register
type TLATBbits = BitField
         LATB0  :1;
         LATB1  :1;
         LATB2  :1;
         LATB3  :1;
         LATB4  :1;
         LATB5  :1;
         LATB6  :1;
         LATB7  :1;
         LATB8  :1;
         LATB9  :1;
         LATB10 :1;
         LATB11 :1;
         LATB12 :1;
         UNK    :3;
  end;

var LATB: TLATBbits; absolute $02CA;
here you find the ??? bitfield , the declaration seems to reserve a number of bits for that symbol. For the time beeing they are not accessible for us i think .

jpc
Posts: 1986
Joined: 22 Apr 2005 17:40
Location: France 87

#3 Post by jpc » 24 Apr 2006 18:50

sorry , i should have looked better : you should take a look in the help under bit fields because that is what we are looking at here.

anton
Posts: 807
Joined: 23 Sep 2004 09:16
Location: South-Africa
Contact:

#4 Post by anton » 24 Apr 2006 21:21

:oops: :oops:

Ok, I also found that button that says 'Help'. Next time I will read it first.

Thank you

Anton
Another proud user of LV 24-33A Development System and mikroPascal PRO for dsPIC :)
PortA not working? Add CMCON := 7; PortD not working? Add ADCON1 := 6;
To paste code on the forum, please use the [b] Code [/b] button !! ;)

Post Reply

Return to “mikroC Beta testing”