How to define port bits ?

General discussion on mikroC PRO for 8051.
Post Reply
Author
Message
Aaron Walsh
Posts: 2
Joined: 12 Oct 2016 14:52

How to define port bits ?

#1 Post by Aaron Walsh » 12 Oct 2016 15:01

Hi, just started using mikroC having used Keil.

I would like to know the correct method for defining a port bit please.

The help shows the following (but I get compiler error "; expected, but '.0' found")

sbit Abit at P1.0;


I tried the following which does not give a compiler error but is it correct ? I have no hardware yet.

sbit Abit at P1_0_bit;


Thank you very much
Aaron

User avatar
nadir.celebic
mikroElektronika team
Posts: 465
Joined: 15 Jun 2016 13:19

Re: How to define port bits ?

#2 Post by nadir.celebic » 13 Oct 2016 16:20

Hi,

Please check some our examples.
http://www.mikroe.com/downloads/get/248 ... p-v360.zip

Code: Select all

TRISA = 0; //set all pins on port A as output
TRISA = 0xFF; //set all pins on port A as input

TRISA.F1 = 1; //set pin 1 as input;
TRISA.B1 = 1; //set pin 1 as input;

PORTA.F3 = 1; //Set 1 for bit 3
PORTA.B3 = 1; //Set 1 for bit 3

RA0_bit = 1; //Set 1 for bit 0;
Regards,
Nadir

Post Reply

Return to “mikroC PRO for 8051 General”