Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to control a pin in mikroC v8.2

Status
Not open for further replies.

OSamra

Newbie level 4
Joined
May 13, 2010
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,319
I'm using PIC18F452 and i wrote this statement "LATD5_bit = 0;" for controlling a pin in MikroC v8.20 but it doesn't work, can anyone tell me why in this version specifically it doesn't work, while on v3.8 it is working???
 

Hi,

The right way to do it in mikroC 8.20 is :

LATD.F5 = 0;
 
  • Like
Reactions: mm_pk1

    mm_pk1

    Points: 2
    Helpful Answer Positive Rating
    V

    Points: 2
    Helpful Answer Positive Rating
Thank you very much it worked, but i just want to know how did know you that, because i've searched alot even in the manual examples of MikroC 8.20v and it was LATD5_bits???
 

Good to hear that ...

From mikroc 8.2 help file look for "Accessing Individual Bits"

mikroC allows you to access individual bits of 8-bit variables, types char and unsigned short. Simply use the direct member selector (.) with a variable, followed by one of identifiers F0, F1, … , F7, with F7 being the most significant bit.

For example:

// If RB0 is set, set RC0:
if (PORTB.F0) PORTC.F0 = 1;There is no need for any special declarations; this kind of selective access is an intrinsic feature of mikroC and can be used anywhere in the code. Identifiers F0–F7 are not case sensitive and have a specific namespace. You may override these with your own members F0–F7 within any given structure.

Provided you are familiar with the particular chip, you can also access bits by name:

// Clear TMR0F:
INTCON.TMR0F = 0;
 
  • Like
Reactions: mm_pk1

    mm_pk1

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top